%MIMOdemo.m
%MIMO detection demonstration
%Zero forcing detection
%Matched filter detection
%Linear minimum mean square estimation
%Low noise
H=randn(2,3);
POS_MMSE=[];
POS_ZF=[];
POS_MF=[];
noisevar=0.1:0.4:4;
SNRlist=1./noisevar;
for v=0.1:0.4:4
SNR=1/v;
LMMSE=[];
MF=[];
ZF=[];
DATA=[];
for i=1:1:2000
X=(1/sqrt(2))*(round(rand(3,1))*2-1)+j*(round(rand(3,1))*2-1);
DATA=[DATA detect(X)];
Y=H*X+sqrt(v/2)*(randn(2,1)+j*randn(2,1));
temp1=pinv((H'*H+(1/SNR)*eye(3)))*H'*Y;
LMMSE=[LMMSE detect(temp1)];
temp2=SNR*H'*Y;
MF=[MF detect(temp2)];
temp3=pinv((H'*H))*H'*Y;
ZF=[ZF detect(temp3)];
end
POS_MMSE=[POS_MMSE 100*length(find((DATA-LMMSE)==0))/length(DATA)];
POS_ZF=[POS_ZF 100*length(find((DATA-ZF)==0))/length(DATA)];
POS_MF=[POS_MF 100*length(find((DATA-MF)==0))/length(DATA)];
end
figure
plot(SNRlist,POS_MMSE,'r')
hold on
plot(SNRlist,POS_ZF,'b')
plot(SNRlist,POS_MF,'k')
detect.m
function [res]=detect(x)
if(real(x)>0)
a=1;
else
a=-1;
end
if(imag(x)>0)
b=1;
else
b=-1;
end
res=a+j*b;
