repetion code in matlab to BPSK

Status
Not open for further replies.

smalhao

Newbie level 1
Joined
Sep 14, 2017
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
7
hello I need help to build a repeater encoder and decoder to check the BER of the BPSK and BFSK modulation in Matlab, my code BPSK is as follows:

%=========================================================================
R = 1;
m = 1; % 1 2 3 4
M = 2^m; % 4^1 4^2 4^3 4^4
k = log2(M); if m>4 error('\nm>4\n'); end;
N = 2^5; % N = 2^7;
SIMS = 1e2; % SIMS = 1e3;
EbNo = 0:2:2; ebno = 10.^(EbNo/10);
EbNober = -4:8; ebnober = 10.^(EbNober/10);
fprintf('===============================================================');
fprintf('\nInicio :: %d :: \n\n');
fprintf('\n===============================================================');
erros = []; ber = []; NeMAX = 1e3; randn('state',0);
%=========================================================================
% bn = randsrc(1,N,[0 1]); % Dados
sn = randsrc(1,N,0:M-1,0);
sm = pskmod(sn,M,0,'gray');
eb = sqrt(abs(mean(sm.^2)));
%=====================Simulation===============================================
for EbN = EbNo, ebn = 10.^(EbN/10); erros = 0;
fprintf('\nEb/No = %+3d dB\t:: erros = ',EbN)
sigma = sqrt(eb/2/ebn);
parfor sims = 1:SIMS
rawgn = [1 1i]*sigma*randn(2,length(sm));
yn = awgn(sm,EbN+10*log10(k),'measured');
% yn = sm +rawgn;
sn_hat = pskdemod(yn,M,0,'gray'); % PSK Demodulator
erros = erros + biterr(sn_hat,sn);
end

ber = [ber erros/(N*k*SIMS)];
fprintf('%6.0f ::\t ', erros);
end,
fprintf('\n===============================================================\n');
toc
fprintf('\n===============================================================\n');
%=======================Theory===============================================
PeMPSK = 2/k*qfunc(sin(pi/(M))*sqrt(2*k*ebnober));
ber_theory = berawgn(EbNober,'psk',M,'nondiff');
%=========================================================================


Best regards
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…