QPSK BER theoretical and simulation doesn't match
Mostra commenti meno recenti
I'm trying to plot the QPSK BER curves for 2 cases, which are:
1- Only AWGN exists
2- Rayleigh fading exists with AWGN
but there's a problem, the theoretical and simulation curves do not match. I've seen other people asking the same question about the curves not matching, but all of them were using a different methods and I'm not allowed to use a different method than ours.
I tried many things such as changing the input type of the pskmod and pskdemod, but the below code was the best I could get. I can't figure out what I'm doing wrong.
Here's the current code:
%% Clean Up
clc;
clear;
close all;
%% Parameters Definition
Eb_No = 0:20; % [dB]
Eb_No_linear = db2pow(Eb_No);
N = 64; % number of symbols
N_iterations = 1000;
M = 4;
Im = log2(M);
Nb = N * Im;
a_msk = 0.85;
a_gmsk = 0.68;
error_awgn = zeros(length(Eb_No), N_iterations);
error_rayleigh_awgn = zeros(length(Eb_No), N_iterations);
BER_awgn = zeros(size(Eb_No));
BER_rayleigh_awgn = zeros(size(Eb_No));
%% Calculating The Theoretical Results
BER_theoretical_awgn = qfunc(sqrt(Eb_No_linear));
BER_theoretical_fading = 1/sqrt(2) * (1 - sqrt( (Eb_No_linear) ./ (2+Eb_No_linear) ));
%% Calculating The Simulation Results
for n = 1:length(Eb_No)
Es_No = Eb_No(n) + 10*log10(Im);
for k = 1:N_iterations
data = randi([0 1], Nb, 1);
x = pskmod(data, M, pi/M, "bin");
h = 1/2 * (randn(size(x)) + 1i*randn(size(x)));
xf = abs(h) .* x;
y = awgn(x, Es_No, "measured");
yf = awgn(xf, Es_No, "measured");
y_est = pskdemod(y, M, pi/M, 'bin');
yf_est = pskdemod(yf, M, pi/M, 'bin');
error_awgn(n, k) = nnz(data ~= y_est);
error_rayleigh_awgn(n, k) = nnz(data ~= yf_est);
end
error_awgn_avg = sum(error_awgn(n, :)) / N_iterations;
error_rayleigh_avg = sum(error_rayleigh_awgn(n, :)) / N_iterations;
BER_awgn(n) = error_awgn_avg / Nb;
BER_rayleigh_awgn(n) = error_rayleigh_avg / Nb;
end
%% Plotting The Theoretical and Simulation results
figure(1);
semilogy(Eb_No, BER_theoretical_awgn, 'r-', 'LineWidth', 1.5);
hold on;
semilogy(Eb_No, BER_awgn, 'r-o', 'LineWidth', 1);
semilogy(Eb_No, BER_theoretical_fading, 'b-', 'LineWidth', 1.5);
semilogy(Eb_No, BER_rayleigh_awgn, 'b-o', 'LineWidth', 1);
grid on;
ylim([10e-5 0.5])
hold off;
ylabel('BER');
xlabel('E_b/N_o');
title('QPSK BER curves for AWGN and Rayleigh');
legend('AWGN_{theory}', 'AWGN_{simulation}', 'Rayleigh_{theory}', 'Rayleigh_{simulation}', 'location', 'best');
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Modulation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

