%  ejecutar BLAST1 y avanzar M con Enter
clear; 
d=.5;
MM=20;
K=4;
SNR=10000000;
fik=[-60 -30 10 20]/180*pi;
%fik=(rand(1,K)-.5)*pi;fik*180/pi
fi=-pi/2:.001:pi/2;
for M=1:MM
    H=exp(-j*((1:M)'-1)*2*pi*d*sin(fik));
    %H=(randn(M,K)+j*randn(M,K))/sqrt(2);
    C=H;M
    Hd=exp(-j*((1:M)'-1)*2*pi*d*sin(fi));
    if M<K
        W=inv(C*C')*C; 
    else
        W=C*inv(C'*C);
        %W=(inv(4/SNR+C'*C)*C')';
    end
    D=abs(W'*Hd);
    plot(fi*180/pi,D,'-'),
    for i=1:K line([fik(i)*180/pi fik(i)*180/pi],[0 2],'Color',[0 0 0]),end,axis([-90 90 0 2])
    set(findobj('Type','line'),'LineWidth',1.5)
    pause
end
