Bit Error Rate (BER) BPSK - Bit error probability (Pb) BPSK

조회 수: 28(최근 30일)
adriane duarte
adriane duarte 2020년 9월 29일
Hello guys
I made a code and plotted the BER curve. Could anyone help me?
I don't know if I plotted the right graph or if I have some wrong information.
Depending on the parameter that I change the graph is very strange.
Could someone give me an idea?
Follow the code below:
clear; close all; clc; tic;
% BPSK
M = 2;
% número de bits ou símbolos
N = 100;
% Gera bits aleatórios ( matriz de variaveis binarias)
Bits_ale = randi([0 M-1],1,N);
% Modulação BPSK 0 -> -1; 1 -> 1
Bits_bpsk = 2 * Bits_ale-1;
% Gera bits de marca d'água aleatórios
Bit_wat = randi([0 M-1],1,N);
Theta = 180/4; % (pi/4)
for k = 1:N
if Bit_wat(k)==1
Bit_enviado(k) = Bits_bpsk(k) * exp(1i * Bits_bpsk(k) * Theta);
else
Bit_enviado(k) = Bits_bpsk(k) * exp(-1i * Bits_bpsk(k) * Theta);
end
end
%generating noise with zero mean and var. equal to 1.
noise=1/sqrt(2)*(randn(1,N)+1i*randn(1,N));
mean(abs(noise.^2)) %test the power of the noise
SNR=0:9; %set SNR in dB
snr_lin=10.^(SNR/10); %calculate linear snr from dB SNR.
y=zeros(length(SNR),N);
%multiply sqrt of snr to signal and add noise:
for i=1:length(SNR)
y(i,:)=real(sqrt(snr_lin(i))*Bit_enviado+noise);
end
%reciever and ber count
err=zeros(length(SNR),N);
Err=zeros(10,2);
for i=1:length(SNR)
for j=1:N
if y(i,j)>=0
y(i,j)=1;
else
y(i,j)=0;
end
end
err(i,:)=abs(y(i,:)- Bits_ale);
Err(i,:)=size(find(err(i,:)));
end
%calculating BER
ber=zeros(length(SNR),1);
for i=1:length(SNR)
ber(i)=Err(i,2)/N;
end
%theoretical BER calculation
theoryBer = 0.5*erfc(sqrt(snr_lin));
semilogy(SNR,ber,'b*-','linewidth',1);
grid on;
hold on;
semilogy(SNR,theoryBer,'r+-','linewidth',1);
grid on;
xlabel('Eb/N0');
ylabel('BER');
legend('Simulation','Theory') ;
toc;

답변(0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by