pls help me write BER codings

1 view (last 30 days)
Janet
Janet on 27 Mar 2012
Pls help me write codings for BER. I have tried many,but get wrong. Wanted to plot BER vs SNR.
clc;
clear all;
close all;
%input
M=1024;
nt=2;
nr=1;
L=65;
%Generate random data
m=4;
msg1=randint(M,1,m);
msg2=randint(M,1,m);
msg=vertcat(msg1,msg2);
% QPSK modulation
qpsk_modulated_data1=pskmod(msg1,m);
qpsk_modulated_data2=pskmod(msg2,m);
%IFFT
x1=ifft(qpsk_modulated_data1);
x2=ifft(qpsk_modulated_data2);
x=vertcat(x1,x2);
%channel
temp=randint(1,L-1);
temp=[temp zeros(1,960)];
temp1=transpose(temp);
h1=gallery('circul',temp1);
h1=h1';
temp2=randint(1,L-1);
temp2=[temp2 zeros(1,960)];
temp3=transpose(temp2);
h2=gallery('circul',temp3);
h2=h2';
h=horzcat(h1,h2);
%r
r=h*x;
%--- Joint estimation of channel response and I/Q imbalance
%ek
e=eye(M);
%y due to cfo
y=e*r;
y1=conj(y);
%z due to cfo and i/q
u=(1+exp(-j*10))/2;
u1=conj(u);
v=(1-exp(j*10))/2;
z=(u*y)+(v*y1);
z1=conj(z);
%a
a=(v/u1);
%ur
a1=abs(a)^2;
e1=conj(e);
ur=(e1*(z-(a*z1))/(1-a1));
%p
p=M/nt;
%MIMO channel response
a1=randn(M,L);
a2=randn(M,L);
A=horzcat(a1,a2);
a11=randn(M,p-L);
a22=randn(M,p-L);
B=horzcat(a1,a11,a2,a22);
B1=inv(B);
ud=B1*ur;
%CRE
q = M-(L*nt);
P = zeros(q,M);
P(:,2:2:end) = (p-L)*eye(q,M/2);
cre=norm(P*ud)^2;
CRE =norm(P*B1*(z-(a*z1)))^2;
%I/Q_imbalance
o=ctranspose(P*B1*z1); %traspose_conj of p*B1*z1
aopt=(o*(P*B1*z))/(norm(P*B1*z1))^2;
%channel response
aopt1=abs(aopt)^2;
cha_res=B1*(z-(aopt*z1))/(1-aopt1);
%--------------------------------------------------%
%fft
fft_recdata=fft(r);
%Demodulate the data
qpsk_demodulated_data = pskdemod(fft_recdata,M);
%estimated signal
est_sgl=r*cha_res';

Accepted Answer

Walter Roberson
Walter Roberson on 27 Mar 2012
There is no obvious place in your code where you use or alter the SNR.
If you were to add noise to your encoded signal before decoding that (noisy) signal, then where would you do that in your code?
  4 Comments
Janet
Janet on 28 Mar 2012
a)first i generate random data
b)then qpsk modulation
c)take ifft of qpsk modulated data
d)pass through channel
e)take fft of received signal
f)qpsk demodulation to recover signal
I have encoded my signal fully in (c) and decode at (f)...I have not added noise now
Walter Roberson
Walter Roberson on 28 Mar 2012
Your step "pass through channel" is the step at which the noise should logically be added, since the channel is the noisy part.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!