% 1. Compute theoretical error rate using BERAWGN.
M =16; EbNo = [0:2:20];
nsamp=1;
ser = berawgn(EbNo,'qam',M).*log2(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.
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
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(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.');
axis([0,20,10^(-7),1]);
legend('Theoretical SER','Empirical SER');
title('Comparing Theoretical and Empirical Error Rates');
hold off;
如果不用symerr(x,z)这个函数来求误码率,该怎样修改呢?
好象是用解调后的信号和原信号怎么比较,设个什么计数器,
比较的结果除以n就是误码率,具体咋写哦,望各位大虾指点,
小第不胜感激~~~~