3

I need help in plotting the Bit error curve or the symbol error curve for BPSK modulation scheme for varying Signal to Noise ratios or Eb/N0. The plot should show the simulated versus the theoretical curve, but I cannot figure out how to mitigate the problems when using the Constant Modulus Algorithm as an Equalizer which are:

(1)

 Error using  * 
Inner matrix dimensions must agree.

Error in BER_BPSK_CMA (line 50)
        yy = w'*x;

(2) I want to use the filter function instead of conv in order to model a moving average channel model, chanOut = filter(ht,1,s). But, when I use filter, I am getting an error. How can I use filter function here?

(3) Bit error rate calculation

UPDATED Code with the Problem 1 solved. However, I am still unable to use filter and unsure if BER curve is proper or not. Below is the code I wrote:

% Script for computing the BER for BPSK modulation in 3 tap ISI 
% channel 


clear
N  = 10^2; % number of bits or symbols
Eb_N0_dB = [0:15]; % multiple Eb/N0 values
K = 3; %number of users
nTap = 3;
mu = 0.001;
   ht = [0.2 0.9 0.3]; 
   L  = length(ht);
for ii = 1:length(Eb_N0_dB)

   % Transmitter
   ip = rand(1,N)>0.5; % generating 0,1 with equal probability
   s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0 

   % Channel model, multipath channel

chanOut = conv(s,ht);
%   chanOut =  filter(ht,1,s);  %MA 
   n = 1/sqrt(2)*[randn(1,N+length(ht)-1) + j*randn(1,N+length(ht)-1)]; % white gaussian noise, 0dB variance 

   % Noise addition
   y = chanOut + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise


   %CMA
  Le =20; %Equalizer length

   e = zeros(N,1);     % error
w = zeros(Le,1);    % equalizer coefficients
w(Le)=1;            % actual filter taps are flipud(w)!  
yd = zeros(N,1);
r = y';
% while(1)
    for i = 1:N-Le,
        x = r(i:Le+i-1);
        %x = r(i:(Le+i-1));
        yy = w'*x;
        yd(i)= yy;
        e(i) = yy^2 - 1;
        mse_signal(ii,i) = mean(e.*e);
        w = w - mu * e(i) * yy * x;

    end

   sb=w'*x;   % estimate symbols (perform equalization)

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

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




end
simBer_CMA = nErr_CMA/N;

theoryBer = 0.5*erfc(sqrt(10.^(Eb_N0_dB/10))); % theoretical ber

for i=1:length(Eb_N0_dB),
   tmp=10.^(i/10);
   tmp=sqrt(tmp);
  theoryBer(i)=0.5*erfc(tmp);
end

figure
semilogy(theoryBer,'b'),grid;
hold on;



semilogy(Eb_N0_dB,simBer_CMA,'r-','Linewidth',2);

%axis([0 14 10^-5 0.5])
grid on
legend('sim-CMA');
xlabel('Eb/No, dB');
ylabel('Bit Error Rate');
title('Bit error probability curve for BPSK in ISI with CMA equalizer');

BER

Ria George
  • 393
  • 1
  • 4
  • 15

2 Answers2

1

There's an error in these three lines:

sb=w'*x;   % estimate symbols (perform equalization)

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

they worked inside the while loop but you are now performing a post-estimation, so the correct lines are:

sb=conv(w,y);   % estimate symbols (perform equalization)

% receiver - hard decision decoding
ipHat = real(sb(Le+1:end-1))>0;   % account for the filter delay

There is still some issue with the output... but I can't go further in the analisys.

NicolaSysnet
  • 486
  • 2
  • 10
  • Exactly! That is why I was getting one sample in equalizer. But, how can I get a proper curve for CMA instead of the flat one. I have tried increasing number of samples = 10^6 but still I keep getting a flat curve. Can you help in this part? – Ria George Oct 19 '15 at 08:06
  • Furthermore, what it the reason behind using convolution and not a linear moving average filter (FIR) because I have read that most equalizers use FIR filter. Basically, conv() we are multiplying the estimated weights/coefficient with the received signal to get the input signal but why should it not be multiplying with the estimated weights with the input to get the received signal and then compare it with the noiseless signal to check if noise has been reduced? – Ria George Oct 19 '15 at 09:07
  • You are trying to plot statistics... and statistics tend to be aleatory. If you want to find a BER of 10^-15 you should simulate 10^18 samples and you will still see artifacts in the plot (how many times would you throw a dice to have a 1/6 probability for a face? 10 times are not enough, neither 100... maybe 1000). – NicolaSysnet Oct 19 '15 at 09:28
  • 1
    To answer your second comment try evaluating `sbb=filter(w,1,[y zeros(1,19)])`, you will see that it will have the same value as `sb=conv(w,y)`. The FIR implementation is very similar to a vector convolution, the difference is that the former gives the same number of samples of the input. To accomodate the filter delay you have, then, to append zeroes to your input. Using conv makes live simpler. – NicolaSysnet Oct 19 '15 at 09:28
0
  1. Your first problem is easily solved: change the line to

    x = y(i:(Le+i-1));
    
  2. Your call of filter looks OK. Which error do you get?

  3. Maybe this is a place to start looking. Or here (would Fig. 4 be the type of plot you're after?)

alle_meije
  • 2,424
  • 1
  • 19
  • 40
  • Thank you for your answers but I am still getting the same error for Problem(1) in the multiplication y=w'x (2) When using the filter(), Matlab gives the error Error using + Matrix dimensions must agree. Error in BER_BPSK_CMA (line 27) y = chanOut + 10^(-Eb_N0_dB(ii)/20)*n; % additive white gaussian noise – Ria George Oct 12 '15 at 19:04
  • Thank you for the BER resources; that has really helped. But I cannot run the code unless Problems in (1) and (2) are resolved. Shall appreciate your help and time. – Ria George Oct 12 '15 at 19:06
  • _(the error is now one line later)_ I'm not really sure what your code is meant to do. If you want `y` to be a scalar, you need to do (row vector)*(column vector). If you want `y` to be a matrix then you need to do (column vector)*(row vector). For a pointwise multiplication you need (vector A).*(vector B) --see the extra dot-- where A and B are the same size. – alle_meije Oct 13 '15 at 07:14
  • y will be a vector ( one row and N columns) representing noisy samples. w represent the weights that are obtained from the CMA equalizer. Using y, I am trying to create an equalizer. The operation yy = w'*x; should give a scalar. Size(w) = 20 by 1; Size(x) = 1 by 20. I have put up the working code including the BER calculation. I have attached the graph as well. I am not sure if this is correct. Also, the filter does not work. Can you please let me know where I am going wrong and how to get proper BER curve. – Ria George Oct 13 '15 at 07:57
  • After the filter command `chanOut` is a 1x100 double array so that works fine (at least on my MatLab). I only have a problem adding the noise because `size(chanOut) ~= size(n)`. But that is easily solved. – alle_meije Oct 15 '15 at 11:23