%spatialdiversity.m
%Generation of pilot signals
LEN=100;
x=(round(rand(1,LEN))*2-1) +j*(round(rand(1,LEN))*2-1);
for i=1:1:5
h(i)=sqrt(0.1)*randn+j*sqrt(0.1)*randn;
end
h=transpose(h);
%received signal
for k=1:1:length(x)
s=[];
for i=1:1:5
s=[s x(k)*h(i)+sqrt(0.005)*randn+j*sqrt(0.005)*randn];
end
y{k}=s;
end
y1=transpose(cell2mat(transpose(y)));
%Estimation of the input signal
for k=1:1:LEN
xest(k)=pinv(h'*h)*h'*transpose(y{k});
end
figure
plot(real(xest)/sum(real(xest)),'m')
hold on
plot(real(y1(1,:)./h(1))/sum(real(y1(1,:)./h(1))),'r')
plot(real(x)/sum(real(x)),'b')
figure
plot(imag(xest),'m')
hold on
plot(imag(y1(2,:)./h(2)'),'r')
plot(imag(x),'b')
