📄 mimo_ofdm.m
字号:
From: <óé Microsoft Internet Explorer 5 ±£′?>
Subject:
Date: Fri, 16 Dec 2005 14:13:16 +0800
MIME-Version: 1.0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.stanford.edu/~smatloub/project1_files/MIMO_OFDM.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR></HEAD>
<BODY><PRE>%------------------------------------------
% EE359 final project, Fall 2002
% Channel estimation for a MIMO-OFDM system
% By Shahriyar Matloub =20
%------------------------------------------
clear all;
%close all;
Rayleigh=3D1;
AWGN=3D0; % for AWGN channel=20
MMSE=3D0; % estimation technique
Nsc=3D64; % Number of subcarriers
Ng=3D16; % Cyclic prefix length
SNR_dB=3D[0 5 10 15 20 25 30 35 40]; % Signal to noise ratio
Mt=3D2; % Number of Tx antennas
Mr=3D2; % Number of Rx antennas
pilots=3D[1:Nsc/Ng:Nsc]; % pilot subcarriers=20
DS=3D15; % Delay spread of channel
iteration_max=3D200;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Channel impulse response %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (Rayleigh)
N=3D50;
fm=3D100;
B=3D20e3;
fd=3D(rand(1,N)-0.5)*2*fm;
theta=3Drandn(1,N)*2*pi;
c=3Drandn(1,N);
c=3Dc/sum(c.^2);
t=3D0:fm/B:10000*fm/B;
Tc=3Dzeros(size(t));
=20
Ts=3Dzeros(size(t));
for k=3D1:N
Tc=3Dc(k)*cos(2*pi*fd(k)*t+theta(k))+Tc;
Ts=3Dc(k)*sin(2*pi*fd(k)*t+theta(k))+Ts;
end
r=3Dones(Mt*Mr,1)*(Tc.^2+Ts.^2).^0.5;
index=3Dfloor(rand(Mt*Mr,DS)*5000+1);
end
MEE1=3Dzeros(1,length(SNR_dB));
MEE2=3Dzeros(1,length(SNR_dB));
for snrl=3D1:length(SNR_dB)
snrl
estimation_error1=3Dzeros(Mt*Mr,Nsc);
estimation_error2=3Dzeros(Mt*Mr,Nsc);
R1=3Dbesselj(0,2*pi*fm*(Nsc+Ng)/B);
sigma2=3D10^(-SNR_dB(snrl)/10);
aa=3D(1-R1^2)/(1-R1^2+sigma2);
bb=3Dsigma2*R1/(1-R1^2+sigma2);
for iteration=3D1:iteration_max
%iteration =20
if AWGN=3D=3D1
h=3Dones(Mt*Mr,1);
else
phi=3Drand*2*pi;
h=3Dr(index+iteration)*exp(i*phi);
%h=3Drand(Mt*Mr,DS);
h=3Dh.*(ones(Mt*Mr,1)*(exp(-0.5).^[1:DS]));
h=3Dh./(sqrt(sum(abs(h).^2,2))*ones(1,DS));
end
CL=3Dsize(h,2); % =
channel length
data_time=3Dzeros(Mt,Nsc+Ng);
data_qam=3Dzeros(Mt,Nsc);
data_out=3Dzeros(Mr,Nsc);
output=3Dzeros(Mr,Nsc);
for tx=3D1:Mt
data_b=3D0*round(rand(4,Nsc)); =
% data
=
data_qam(tx,:)=3Di*(2*(mod(data_b(1,:)+data_b(2,:),2)+2*data_b(1,:))-3)+.=
..
2*(mod(data_b(3,:)+data_b(4,:),2)+2*data_b(3,:))-3;
for loop=3D1:Mt=20
data_qam(tx,pilots+loop-1)=3D(1+i)*(loop=3D=3Dtx); =
% pilots
end
data_time_temp=3Difft(data_qam(tx,:));
data_time(tx,:)=3D[data_time_temp(end-Ng+1:end) =
data_time_temp];
end
=20
for rx=3D1:Mr
for tx=3D1:Mt
output_temp=3Dconv(data_time(tx,:),h((rx-1)*Mt+tx,:));
output(rx,:)=3Doutput_temp(Ng+1:Ng+Nsc)+output(rx,:);
end
=
np=3D(sum(abs(output(rx,:)).^2)/length(output(rx,:)))*sigma2;
=
noise=3D(randn(size(output(rx,:)))+i*randn(size(output(rx,:))))*sqrt(np);=
output(rx,:)=3Doutput(rx,:)+noise;
data_out(rx,:)=3Dfft(output(rx,:));
end
%%%%%%%%%%%%%%%%%%%%%%
% Channel estimation %
%%%%%%%%%%%%%%%%%%%%%%
=20
H_act=3Dzeros(Mt*Mr,Nsc);
H_est1=3Dzeros(Mt*Mr,Nsc);
H_est2=3Dzeros(Mt*Mr,Nsc);
i=3D1;
for tx=3D1:Mt
for rx=3D1:Mr
=
H_est_temp=3Ddata_out(rx,pilots+tx-1)./data_qam(tx,pilots+tx-1);
=
%H_est_temp2=3Daa*abs(H_est_temp1)+bb*abs(H_est2((rx-1)*Mt+tx,:));
h_time=3Difft(H_est_temp);
h_time=3D[h_time zeros(1,Nsc-length(h_time))];
H_est1((rx-1)*Mt+tx,:)=3Dfft(h_time);
=
H_est2((rx-1)*Mt+tx,:)=3D((aa*abs(H_est1((rx-1)*Mt+tx,:))+bb*abs(H_est2((=
rx-1)*Mt+tx,:)))...
=
.*H_est1((rx-1)*Mt+tx,:))./abs(H_est1((rx-1)*Mt+tx,:));
if (tx>1)
=
H_est1((rx-1)*Mt+tx,:)=3D[H_est1((rx-1)*Mt+tx,Nsc-tx+2:Nsc) =
H_est1((rx-1)*Mt+tx,1:Nsc-tx+1)];
=
H_est2((rx-1)*Mt+tx,:)=3D[H_est2((rx-1)*Mt+tx,Nsc-tx+2:Nsc) =
H_est2((rx-1)*Mt+tx,1:Nsc-tx+1)]; =20
end
H_act((rx-1)*Mt+tx,:)=3Dfft([h((rx-1)*Mt+tx,:) =
zeros(1,Nsc-CL)]);
=
error1=3D(abs(H_act((rx-1)*Mt+tx,:)-H_est1((rx-1)*Mt+tx,:)).^2);
=
error2=3D(abs(H_act((rx-1)*Mt+tx,:)-H_est2((rx-1)*Mt+tx,:)).^2);
=
%error=3D(abs(H_act((rx-1)*Mt+tx,:)-H_est((rx-1)*Mt+tx,:)).^2)./(abs(H_ac=
t((rx-1)*Mt+tx,:)).^2);
=
estimation_error1((rx-1)*Mt+tx,:)=3Destimation_error1((rx-1)*Mt+tx,:)+err=
or1; =20
=
estimation_error2((rx-1)*Mt+tx,:)=3Destimation_error2((rx-1)*Mt+tx,:)+err=
or2;=20
=
%subplot(Mt*Mr,3,i),plot([0:Nsc-1],abs(H_act((rx-1)*Mt+tx,:))); i=3Di+1;
=
%subplot(Mt*Mr,3,i),plot([0:Nsc-1],abs(H_est((rx-1)*Mt+tx,:))); i=3Di+1;
%subplot(Mt*Mr,3,i),plot([0:Nsc-1],abs(error)); i=3Di+1;
end
end =20
end
estimation_error1=3Destimation_error1/iteration_max;
estimation_error2=3Destimation_error2/iteration_max;
=
%estimation_error=3Dmin(estimation_error,10*iteration_max*ones(size(estim=
ation_error)));
%for i=3D1:Mt*Mr
% subplot(Mt*Mr,2,2*i-1),plot([0:Nsc-1],estimation_error1(i,:)); =
=20
% subplot(Mt*Mr,2,2*i),plot([0:Nsc-1],estimation_error2(i,:));
%end
MEE1(snrl)=3Dsum(sum(estimation_error1))/(Mt*Mr*Nsc);
MEE2(snrl)=3Dsum(sum(estimation_error2))/(Mt*Mr*Nsc);
end
%plot(SNR_dB,10*log10(MEE1)); =20
%hold on;
plot(SNR_dB,10*log10(MEE2),'r');
%H_act=3Dfft([h zeros(1,Nsc-CL)]).';
%error1=3D(abs(H_act-H_est1).^2)./(abs(H_act).^2);
%error2=3D(abs(H_act-H_est2).^2)./(abs(H_act).^2);
%%%%%%%%%
% Plots %
%%%%%%%%%
%fig=3D4;
%i=3D1;
%subplot(fig,1,i),plot([0:length(H_act)-1],abs(H_act)); i=3Di+1;
%subplot(fig,1,i),plot([0:length(H_est1)-1],abs(H_est1)); i=3Di+1;
%subplot(fig,1,i),plot([0:length(H_est2)-1],abs(H_est2)); i=3Di+1;
%subplot(fig,1,i),plot([0:length(error1)-1],error1); i=3Di+1;
%subplot(fig,1,i),plot([0:length(error2)-1],error2);
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -