Construct Repetion code to BPSK
Show older comments
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)));
repetion code %=====================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
Answers (0)
Categories
Find more on BPSK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!