Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

fix matlab code % Define parameters M = [ 2 , 4 , 8 ] ; % Modulation orders num _ symbols = 1 e

fix matlab code
% Define parameters
M =[2,4,8]; % Modulation orders
num_symbols =1e6; % Number of symbols to simulate
SNR_db =-2:2:20; % SNR range in dB
EbN_db = SNR_db -10*log10(log2(M)); % Convert SNR to Eb/N in dB
% Initialize variables
theoretical_SER_psk = zeros(length(EbN_db),1);
theoretical_SER_mfsk = zeros(length(EbN_db),1);
simulated_SER = zeros(length(EbN_db), length(M));
% Loop through modulation schemes
for m =1:length(M)
% Loop through Eb/N values
for i =1:length(EbN_db)
% Generate random symbols
data_bits = randi(M, num_symbols, 1);
% Modulate symbols
if m ==1
modulated_signal = pskmod(data_bits, M);
else
modulated_signal = fskmod(data_bits, M,2);
end
% Add AWGN noise
received_signal = awgn(modulated_signal, EbN_db(i));
% Demodulate symbols
if m ==1
demodulated_data = pskdemod(received_signal, M);
else
demodulated_data = fskdemod(received_signal, M,2);
end
% Calculate symbol error rate
simulated_SER(i, m)= sum(data_bits ~= demodulated_data)/ num_symbols;
% Theoretical symbol error rate (MPSK)
theoretical_SER_psk(i)= qfunc(sqrt(2*10^(EbN_db(i)/10)));
% Theoretical symbol error rate (MFSK)
theoretical_SER_mfsk(i)=(1-1/M)* qfunc(sqrt(3/(M-1)*10^(EbN_db(i)/10)));
end
end
% Plot results
figure;
semilogy(EbN_db, theoretical_SER_psk,'b-', 'LineWidth', 2);
hold on;
semilogy(EbN_db, theoretical_SER_mfsk,'g-', 'LineWidth', 2);
for m =1:length(M)
semilogy(EbN_db, simulated_SER(:, m),'o-', 'MarkerSize', 8);
end
xlabel('Eb/N (dB)');
ylabel('Symbol Error Rate (SER)');
title('SER vs. Eb/N for MPSK and MFSK');
legend('MPSK Theory', 'MFSK Theory', 'M=2 Simulation', 'M=4 Simulation', 'M=8 Simulation');
grid on;
% Compare results
disp('Observations:');
for m =1:length(M)
disp(['For M=', num2str(M(m)),':']);
disp(['- Simulated SER generally agrees with theoretical SER for high Eb/N.']);
disp(['- At low Eb/N, simulated SER may deviate slightly due to simulation limitations.']);
end
Arrays have incompatible sizes for this operation.
Related documentation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 2 Lncs 8056

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013th Edition

3642401724, 978-3642401725

More Books

Students also viewed these Databases questions

Question

What will you do or say to Anthony about this issue?

Answered: 1 week ago