Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all;
- close all;
- bits_tr = 10000;
- % SNR in dB
- SNR_dB=1:1:10;
- % SNR on linear scale
- SNR=10.^(SNR_dB/10);
- ber_net = zeros(1, length(SNR_dB));
- for curr_SNR=1:1:10
- %Quadrature Component of Signal
- SQ=2*(round(rand(1,bits_tr))-0.5);
- %InPhase Component of signal
- SI = 2*(round(rand(1,bits_tr))-0.5);
- % Signal = Inphase Component + jQuadrature Component
- S = SI + j*SQ;
- % Add Additive White Gaussian Noise to the Signal
- % The snr is SNR_dB and "measured" is passed inorder to measure
- % signal power of input signal, else defaulted to 0
- % Thus signal recieved is S + AWGN
- R = awgn(S,curr_SNR,'measured');
- %Extract inphase and quadrature of recieved signal using signum
- %function
- SI_y=sign(real(R));
- SQ_y=sign(imag(R));
- % Bit Error in inphase component
- ber_inphase=(bits_tr-sum(SI==SI_y))/bits_tr;
- % Bit Error in quadrature component
- ber_quad=(bits_tr-sum(SQ==SQ_y))/bits_tr;
- % Net Bit Error
- ber_net(curr_SNR)=mean([ber_inphase ber_quad]);
- disp(ber_net)
- end
- semilogy(SNR_dB,ber_net,'-mh')
- xlabel('Signal to noise ratio (dB)');
- ylabel('Bit error rate');
- title('QPSK with AWGN');
- grid on;
Advertisement
Add Comment
Please, Sign In to add comment