mghaly
Newbie level 2
Dear all,
i want to compare between exact and simulated SER of QPSK using Matlab through a graph. I've written the code, but for some kind of reason the simulated SER appears to be horizontal line, instead of decaying exponential. so please can someone help me to correct the mistake in the simulation. I've included my code. please help.
CODE:
clc
clear
N = 10^5; % number of symbols
i1 = [1:0.5:11]; % multiple Eb/N0 values
ref = zeros(1,N);
for ii = 1:length(i1)
stream = (randint(1,N)) + j*(randint(1,N));
s = (1/sqrt(2))*stream; % normalization of energy to 1
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white guassian noise
y = s + (sqrt(10^(-i1(ii)/10))*n); % additive white gaussian noise
% decoding
y_re = real; % real
y_im = imag; % imaginary
ref(find(y_re < 0 & y_im < 0)) = -1 + -1*j;
ref(find(y_re >= 0 & y_im > 0)) = 1 + 1*j;
ref(find(y_re < 0 & y_im >= 0)) = -1 + 1*j;
ref(find(y_re >= 0 & y_im < 0)) = 1 - 1*j;
nErr(ii) = size(find([stream- ref]),2); % couting the number of errors
end
SER_QPSK = nErr/N;
theory_QPSK = erfc(sqrt(0.5*(10.^(i1/10)))) - (1/4)*(erfc(sqrt(0.5*(10.^(i1/10))))).^2;
close all
figure
semilogy(i1,theory_QPSK,'b.-');
hold on
semilogy(i1,SER_QPSK,'r-');
axis([0.9 15 10^-4 1])
grid on
legend('theory-QPSK', 'simulation-QPSK');
xlabel('Es/No, dB')
ylabel('Symbol Error Rate')
title('Symbol error probability curve for QPSK')
i want to compare between exact and simulated SER of QPSK using Matlab through a graph. I've written the code, but for some kind of reason the simulated SER appears to be horizontal line, instead of decaying exponential. so please can someone help me to correct the mistake in the simulation. I've included my code. please help.
CODE:
clc
clear
N = 10^5; % number of symbols
i1 = [1:0.5:11]; % multiple Eb/N0 values
ref = zeros(1,N);
for ii = 1:length(i1)
stream = (randint(1,N)) + j*(randint(1,N));
s = (1/sqrt(2))*stream; % normalization of energy to 1
n = 1/sqrt(2)*[randn(1,N) + j*randn(1,N)]; % white guassian noise
y = s + (sqrt(10^(-i1(ii)/10))*n); % additive white gaussian noise
% decoding
y_re = real; % real
y_im = imag; % imaginary
ref(find(y_re < 0 & y_im < 0)) = -1 + -1*j;
ref(find(y_re >= 0 & y_im > 0)) = 1 + 1*j;
ref(find(y_re < 0 & y_im >= 0)) = -1 + 1*j;
ref(find(y_re >= 0 & y_im < 0)) = 1 - 1*j;
nErr(ii) = size(find([stream- ref]),2); % couting the number of errors
end
SER_QPSK = nErr/N;
theory_QPSK = erfc(sqrt(0.5*(10.^(i1/10)))) - (1/4)*(erfc(sqrt(0.5*(10.^(i1/10))))).^2;
close all
figure
semilogy(i1,theory_QPSK,'b.-');
hold on
semilogy(i1,SER_QPSK,'r-');
axis([0.9 15 10^-4 1])
grid on
legend('theory-QPSK', 'simulation-QPSK');
xlabel('Es/No, dB')
ylabel('Symbol Error Rate')
title('Symbol error probability curve for QPSK')
Last edited: