Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Pls help me spot errors in the code..I don't get a decaying BER
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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=randsrc(1,L-1);
temp=[temp zeros(1,960)];
temp1=transpose(temp);
h1=gallery('circul',temp1);
h1=h1';
temp2=randsrc(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';
%calculating BER
errors=0;
snr=0:1:35;
for k=1:length(snr)
for i=1:M
if est_sgl(i) ~= msg(i)
errors=errors+1;
end
end
ber(k)=errors/M;
Q=sort(ber,'descend');
end
figure(1)
semilogy(smooth(snr),smooth(Q));
title('BER vs SNR');
ylabel('BER');
xlabel('SNR');
3 Commenti
Jan
il 22 Mar 2012
Please, Janet, explain what error you see. Do you get an error message (if so, post it completely) or do the results differ from your expectations?
Risposte (1)
Walter Roberson
il 22 Mar 2012
The problem is the same as I told you before more than once: you are not recalculating your noise signal as you change your snr, so your number of errors is coming out constant for each snr.
12 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!