ashutoshbb

Untitled

Aug 24th, 2021
1,754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.41 KB | None | 0 0
  1. clear all;                                            
  2. close all;
  3.  
  4. bits_tr = 10000;
  5. % SNR in dB
  6. SNR_dB=1:1:10;
  7. % SNR on linear scale
  8. SNR=10.^(SNR_dB/10);
  9.  
  10. ber_net = zeros(1, length(SNR_dB));
  11. for curr_SNR=1:1:10
  12.    
  13.     %Quadrature Component of Signal
  14.     SQ=2*(round(rand(1,bits_tr))-0.5);
  15.     %InPhase Component of signal
  16.     SI = 2*(round(rand(1,bits_tr))-0.5);                      
  17.     % Signal = Inphase Component + jQuadrature Component
  18.     S = SI + j*SQ;                              
  19.     % Add Additive White Gaussian Noise to the Signal
  20.     % The snr is SNR_dB and "measured" is passed inorder to measure
  21.     % signal power of input signal, else defaulted to 0
  22.     % Thus signal recieved is S + AWGN
  23.     R = awgn(S,curr_SNR,'measured');
  24.     %Extract inphase and quadrature of recieved signal using signum
  25.     %function
  26.     SI_y=sign(real(R));                                
  27.     SQ_y=sign(imag(R));                        
  28.     % Bit Error in inphase component
  29.     ber_inphase=(bits_tr-sum(SI==SI_y))/bits_tr;                          
  30.     % Bit Error in quadrature component
  31.     ber_quad=(bits_tr-sum(SQ==SQ_y))/bits_tr;    
  32.     % Net Bit Error
  33.     ber_net(curr_SNR)=mean([ber_inphase ber_quad]);                        
  34.     disp(ber_net)
  35. end
  36.  
  37. semilogy(SNR_dB,ber_net,'-mh')
  38.  
  39. xlabel('Signal to noise ratio (dB)');
  40. ylabel('Bit error rate');      
  41.  
  42. title('QPSK with AWGN');
  43.  
  44.  
  45. grid on;
Advertisement
Add Comment
Please, Sign In to add comment