السلام عليكم ورحمة الله وبركاته.
البرنامج التالي هو من الـ Help للماتلاب تحت عنوان Comparing Theoretical and Empirical Error Rates ويعمل بشكل طبيعي :-
% Comparing Theoretical and Empirical Error Rates
%
% The example below uses the berawgn function to compute symbol error rates for pulse amplitude modulation (PAM) with a series of Eb/N0 values. For comparison, the code simulates 8-PAM with an AWGN channel and computes empirical symbol error rates. The code also plots the theoretical and empirical symbol error rates on the same set of axes.
%
% 1. Compute theoretical error rate using BERAWGN.
M = 8; EbNo = [0:13];
[ber, ser] = berawgn(EbNo,‘pam’,M);
% Plot theoretical results.
figure; semilogy(EbNo,ser,‘r’);
xlabel(‘E_b/N_0 (dB)’); ylabel(‘Symbol Error Rate’);
grid on; drawnow;
% 2. Compute empirical error rate by simulating.
% Set up.
n = 10000; % Number of symbols to process
k = log2(M); % Number of bits per symbol
% Convert from EbNo to SNR.
% Note: Because No = 2*noiseVariance^2, we must add 3 dB
% to get SNR. For details, see Proakis book listed in
% “Selected Bibliography for Performance Evaluation.”
snr = EbNo+3+10*log10(k);
ynoisy=zeros(n,length(snr)); % Preallocate to save time.
% Main steps in the simulation
x = randint(n,1,M); % Create message signal.
y = pammod(x,M); % Modulate.
% Send modulated signal through AWGN channel.
% Loop over different SNR values.
for jj = 1:length(snr)
ynoisy(:,jj) = awgn(real(y),snr(jj),‘measured’);
end
z = pamdemod(ynoisy,M); % Demodulate.
% Compute symbol error rate from simulation.
[num,rt] = symerr(x,z);
% 3. Plot empirical results, in same figure.
hold on; semilogy(EbNo,rt,‘b.’);
legend(‘Theoretical SER’,‘Empirical SER’);
title(‘Comparing Theoretical and Empirical Error Rates’);
hold off;
[RIGHT]
[RIGHT]
لكن أريد أن أحول البرنامج من 8-PAM ليعمل على 16QAM ولم أفلح بذلك حيث أن البرنامج الذي استخدمته هو:-
% Comparing Theoretical and Empirical Error Rates
%
% The example below uses the berawgn function to compute symbol error rates for pulse amplitude modulation (PAM) with a series of Eb/N0 values. For comparison, the code simulates 8-PAM with an AWGN channel and computes empirical symbol error rates. The code also plots the theoretical and empirical symbol error rates on the same set of axes.
%
% 1. Compute theoretical error rate using BERAWGN.
M = 16; EbNo = [0:13];
[ber, ser] = berawgn(EbNo,‘qam’,M);
% Plot theoretical results.
figure; semilogy(EbNo,ser,‘r’);
xlabel(‘E_b/N_0 (dB)’); ylabel(‘Symbol Error Rate’);
grid on; drawnow;
% 2. Compute empirical error rate by simulating.
% Set up.
n = 10000; % Number of symbols to process
k = log2(M); % Number of bits per symbol
% Convert from EbNo to SNR.
% Note: Because No = 2*noiseVariance^2, we must add 3 dB
% to get SNR. For details, see Proakis book listed in
% “Selected Bibliography for Performance Evaluation.”
snr = EbNo+3+10*log10(k);
ynoisy=zeros(n,length(snr)); % Preallocate to save time.
% Main steps in the simulation
x = randint(n,1,M); % Create message signal.
y = qammod(x,M); % Modulate.
% Send modulated signal through AWGN channel.
% Loop over different SNR values.
for jj = 1:length(snr)
ynoisy(:,jj) = awgn(real(y),snr(jj),‘measured’);
end
z = qamdemod(ynoisy,M); % Demodulate.
% Compute symbol error rate from simulation.
[num,rt] = symerr(x,z);
% 3. Plot empirical results, in same figure.
hold on; semilogy(EbNo,rt,‘b.’);
legend(‘Theoretical SER’,‘Empirical SER’);
title(‘Comparing Theoretical and Empirical Error Rates 16QAM’);
hold off;
أرجو المساعدة لتصحيح البرنامج ليعمل على 16QAM وبصورة عامة على MQAM
يبدو أن الرسمين لم يظهرا في الصفحة. لايهم
وبارك الله فيكم وجزاكم خيرا.