Why does the BER rate change randomly versus the SNR? 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



BER vs SNR

clear
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)&gt;0.5; % generating 0,1 with equal probability
   s = 2*ip-1; % BPSK modulation 0 -&gt; -1; 1 -&gt; 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)&gt;0;

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

end

simBer = nErr/N; % simulated ber
semilogy(Eb_N0_dB,simBer,'mx-');
grid on
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for BPSK modulation');
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.