Question: fix matlab code % Define parameters M = [ 2 , 4 , 8 ] ; % Modulation orders num _ symbols = 1 e
fix matlab code
Define parameters
M ; Modulation orders
numsymbols e; Number of symbols to simulate
SNRdb ::; SNR range in dB
EbNdb SNRdb loglogM; Convert SNR to EbN in dB
Initialize variables
theoreticalSERpsk zeroslengthEbNdb;
theoreticalSERmfsk zeroslengthEbNdb;
simulatedSER zeroslengthEbNdb lengthM;
Loop through modulation schemes
for m :lengthM
Loop through EbN values
for i :lengthEbNdb
Generate random symbols
databits randiM numsymbols, ;
Modulate symbols
if m
modulatedsignal pskmoddatabits, M;
else
modulatedsignal fskmoddatabits, M;
end
Add AWGN noise
receivedsignal awgnmodulatedsignal, EbNdbi;
Demodulate symbols
if m
demodulateddata pskdemodreceivedsignal, M;
else
demodulateddata fskdemodreceivedsignal, M;
end
Calculate symbol error rate
simulatedSERi m sumdatabits ~ demodulateddata numsymbols;
Theoretical symbol error rate MPSK
theoreticalSERpski qfuncsqrtEbNdbi;
Theoretical symbol error rate MFSK
theoreticalSERmfskiM qfuncsqrtMEbNdbi;
end
end
Plot results
figure;
semilogyEbNdb theoreticalSERpskb 'LineWidth', ;
hold on;
semilogyEbNdb theoreticalSERmfskg 'LineWidth', ;
for m :lengthM
semilogyEbNdb simulatedSER: mo 'MarkerSize', ;
end
xlabelEbN dB;
ylabelSymbol Error Rate SER;
titleSER vs EbN for MPSK and MFSK;
legendMPSK Theory', MFSK Theory', M Simulation', M Simulation', M Simulation';
grid on;
Compare results
dispObservations:;
for m :lengthM
dispFor M numstrMm:;
disp Simulated SER generally agrees with theoretical SER for high EbN;
disp At low EbN 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
