pls help me write BER codings

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';

 採用された回答

Walter Roberson
Walter Roberson 2012 年 3 月 27 日

0 投票

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 件のコメント

Janet
Janet 2012 年 3 月 28 日
I really don't know what and how to do it. I can understand what you say, but still clueless of what to do. I tried adding
for snr=0:1:35 after giving input, but the program runs endlessly.
Walter Roberson
Walter Roberson 2012 年 3 月 28 日
At what point in your code have you completely constructed your encoded signal? After which you start decoding the signal and analyzing that? If you wrote the code, surely you must be able to break it up into a signal construction phase and a signal analysis phase?
You should be able to write your code in sections using distinct routines:
A) initialization including constructing the "known" message;
B) passing the known message in to a routine for encoding, returning a signal
C) adding noise to the signal according to an input SNR
D) decoding the noisy signal, returning an experimental decoded message (perhaps with "violation detected" markers)
E) computing the similarity of the original message and the experimental decoded message to calculate a BER for that SNR
F) looping back for a different SNR. Or, if the corruption is random, even for the same SNR in order to get a range of BER for the same SNR
G) plot the BER vs SNR.
I can write the above outline even though I do not know the message encoding technique: that is a detail that matters only to the encoding phase (B) and the decoding phase (D).
Janet
Janet 2012 年 3 月 28 日
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 2012 年 3 月 28 日
Your step "pass through channel" is the step at which the noise should logically be added, since the channel is the noisy part.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePHY Components についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by