clear all;
close all;
clc;
%%设置信号为窄带信号,幅度为1
S=[1,1,1]
imag1=sqrt(-1);
element_num=8;%阵元数为8
d_lamda=1/2;%阵元间距d与波长lamda的关系
theta=linspace(-pi/2,pi/2,2000);
theta0=0/180*pi;%来波方向 (我觉得应该是天线阵的指向)
%theta0=0;%来波方向
theta1=12/180*pi;
theta2=30/180*pi;
L=20;
L1=200;
L2=500;
kk_sum=0;
SNR=8;
w_l0=exp(-imag1*2*pi*d_lamda*sin(theta0)*[0:element_num-1]');
w_l1=exp(-imag1*2*pi*d_lamda*sin(theta1)*[0:element_num-1]');
w_l2=exp(-imag1*2*pi*d_lamda*sin(theta2)*[0:element_num-1]');
A=[w_l0,w_l1,w_l2];
S0=randn(length(S),L);
S1=randn(length(S),L1);
S2=randn(length(S),L2)
x=A*S0;
x1=A*S1;
x2=A*S2;
X=awgn(x,SNR,'measured');
X1=awgn(x1,SNR,'measured');
X2=awgn(x2,SNR,'measured');
R=X*X'/L;
R1=X1*X1'/L1;
R2=X2*X2'/L2;
[V,D]=eig(R);
[V1,D1]=eig(R1);
[V2,D2]=eig(R2);
Ci=inv(R);
Ci1=inv(R1);
Ci2=inv(R2);
for j=1:length(theta) %(我认为是入射角度,即来波方向,计算阵列流形矩阵A)
a=exp(-imag1*2*pi*d_lamda*sin(theta(j))*[0:element_num-1].');
p(j)=1/(a'*Ci*a); %(matlab中的'默认为共轭转置,如果要计算转置为w.'*a)
p1(j)=1/(a'*Ci1*a);
p2(j)=1/(a'*Ci2*a);
end,
figure(1)
plot(theta*180/pi,db(abs(p)/max(abs(p))),'red');
hold on;
plot(theta*180/pi,db(abs(p1)/max(abs(p1))),'green');
hold on;
plot(theta*180/pi,db(abs(p2)/max(abs(p2))));
xlabel('角度/°');
ylabel('归一化增益/dB');
title('20,200,500快拍数时capon算法天线方向图');
legend('20','200','500')
figure(2) %绘出应用MUSIC法估计的波达方向图
polar(theta,abs(p),'red');
hold on;
polar(theta,abs(p1),'green');
hold on;
polar(theta,abs(p2));
legend('20','200','500')
%axis([-90 90 -60 0]);
评论2
最新资源