clear all
close all
clc
N=16;%阵元个数
En_n=0.5;
snap_num=64;%快拍数
c=3e+8;%c为光速
fc=500e6;%雷达工作频率
wavelength=c/fc;%波长
d=wavelength/2;%阵元间距
theta_0=25*pi/180;%来波方向
theta_1=pi/6;
theta_2=pi/3;
% theta_0=0;
% theta_1=pi/9;
% theta_2=pi/6;
theta=-pi/2:pi/180:pi/2;
steer_sig_0=exp(j*2*pi*(0:N-1)'*sin(theta_0)*d/wavelength);%信号导向矢量
steer_sig_1=exp(j*2*pi*(0:N-1)'*sin(theta_1)*d/wavelength);
steer_sig_2=exp(j*2*pi*(0:N-1)'*sin(theta_2)*d/wavelength);
snap_sig_0=steer_sig_0*(randn(1,snap_num)+j*randn(1,snap_num))/sqrt(2);%snap_num个采样数据
snap_sig_1=steer_sig_1*(randn(1,snap_num)+j*randn(1,snap_num))/sqrt(2);
snap_sig_2=steer_sig_2*(randn(1,snap_num)+j*randn(1,snap_num))/sqrt(2);
% input_x=snap_sig_0+snap_sig_1+snap_sig_2;
% Rx=(input_x*input_x')/snap_num+En_n*eye(N);
input_x=snap_sig_0+1.5*snap_sig_1+1.5*snap_sig_2+En_n*(randn(N,snap_num)+j*randn( N,snap_num))/sqrt(2);
Rx=(input_x*input_x')/snap_num;
r=rank(Rx);
x=1:r;
[V,D]=eig(Rx);
D=diag(D);
M=0;
for m=1:r
if D(m)<1
M=M+1;
v(:,M)=V(:,m);
end
end
M_0=r-M;
Pn=v*v';
steer=exp(j*2*pi*(0:N-1)'*sin(theta)*d/wavelength);%搜索矢量
for m=1:length(theta)