I have altered a MATLAB code that simulates the BPSK modulation using a raised cosine filter at the transmitter and a matched filter at the receiver to study how the signal changes in each step. But, the final plot of the BER versus SNR is not decreasing as the SNR increases. I have no clue how to fix this. I would appreciate any help. The image and code is below



N  = 10^6; % number of bits or symbols
T  = 1; % symbol duration of 1us 
os = 5; % oversampling factor
fs = 5/T; % sampling frequency in MHz
rolloff = 0.05;

Eb_N0_dB = [0:10]; % multiple Eb/N0 values

for ii = 1:length(Eb_N0_dB)
    filter = rcosine(1/T,os,'sqrt',rolloff);
   % Transmitter
   ip = rand(1,N)>0.5; % generating 0,1 with equal probability
   s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 1 

   % up sampling the signal for transmission
   sU = [s;zeros(os-1,length(s))];
   sU = sU(:).';
   sFilt = 1/sqrt(os)*conv(sU,filter);
   sFilt = sFilt(1:N*os);

   % Noise addition
   y= awgn(sFilt,ii,0); 

   % mathched filter
   yFilt = conv(y,fliplr(filter)); % convolution
   ySamp = yFilt(os:os:N*os);  % sampling at time T

   % receiver - hard decision decoding
   ipHat = real(ySamp)>0;

   % counting the errors
   nErr(ii) = size(find([ip- ipHat]),2);


simBer = nErr/N; % simulated ber
grid on
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for BPSK modulation');
  • $\begingroup$ I seems to me that you are not considering the delay induced by both filtering stages. $\endgroup$
    – vaz
    Dec 10, 2015 at 15:10
  • $\begingroup$ @vaz Could you please elaborate further? $\endgroup$
    – user29568
    Dec 10, 2015 at 15:31
  • 1
    $\begingroup$ With a BER hovering around $0.5$ regardless of the SNR, whatever you are doing with your modified code is so destructive of the receiver performance that you might as well junk the whole thing and choose the value of the output bits by tossing a coin! $\endgroup$ Dec 10, 2015 at 15:53

1 Answer 1


There are a few problems with your code:

  • You are using the index ii not the actual SNR in DB in this line: y= awgn(sFilt,ii,0);

  • You are not taking into account the filter delay in ySamp = yFilt(os:os:N*os);. Your filter is filter = rcosine(1/T,os,'sqrt',rolloff); which will design a root-raised cosine FIR filter. Your filter delay will be (length(filter)-1)/2.

  • $\begingroup$ If ip=0, then isn't s=0-1 =-1? Also, I didn't quite understand how I can take the filter delay into account. $\endgroup$
    – user29568
    Dec 10, 2015 at 15:23
  • $\begingroup$ You are correct! I missed the s line. I'm just reading code, I have no way to run it. $\endgroup$
    – Peter K.
    Dec 10, 2015 at 15:58
  • $\begingroup$ @user29568 : See my addition about how to deal with filter delay. $\endgroup$
    – Peter K.
    Dec 10, 2015 at 16:04
  • $\begingroup$ Wouldn't that change the vector size, causing the comparison to produce a dimension error? $\endgroup$
    – user29568
    Dec 10, 2015 at 16:08
  • $\begingroup$ or should I prepend the zeros before filtering $\endgroup$
    – user29568
    Dec 10, 2015 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.