%仿真条件:16阵元,1个期望信号0度入射,1个干扰40度入射
%绘制5个图:波束形成图,波束圆图、不同步长因子均方误差图、不同步长因子的波束图、不同阵元间距波束图
%天线接收信号
clear all
close all
% clc
Na=16;
N=1000;
angtorad=pi/180;
%不同步长因子
d=0.5;
u=5e-6;
[W_LMS, Y_LMS, er]=LMS_function_d_u( d , u);
W_LMS1=W_LMS;
Y_LMS1=Y_LMS;
er1=er;
d=0.5;
u=5e-7;
[W_LMS, Y_LMS, er]=LMS_function_d_u( d , u);
W_LMS2=W_LMS;
Y_LMS2=Y_LMS;
er2=er;
%波束形成
Length=300;
B_LMS1=zeros(1,Length);
B_LMS2=zeros(1,Length);
angle1=linspace(-pi/2,pi/2,Length);
%计算阵列流形矩阵A
for i=1:length(angle1)
Aa=exp(-j*2*pi*d*sin(angle1(i))*[0:Na-1]');
B_LMS1(i)=20*log10(abs(W_LMS1'*Aa));
B_LMS2(i)=20*log10(abs(W_LMS2'*Aa));
end
%不同阵元间距
d=0.25;
u=5e-6;
[W_LMS, Y_LMS, er]=LMS_function_d_u( d , u);
d1=d;
W_LMS_d1=W_LMS;
Y_LMS_d1=Y_LMS;
d=0.5;
u=5e-6;
[W_LMS, Y_LMS, er]=LMS_function_d_u( d , u);
d2=d;
W_LMS_d2=W_LMS;
Y_LMS_d2=Y_LMS;
d=1;
u=5e-6;
[W_LMS, Y_LMS, er]=LMS_function_d_u( d , u);
d3=d;
W_LMS_d3=W_LMS;
Y_LMS_d3=Y_LMS;
%波束形成
Length=300;
B_LMS_d1=zeros(1,Length);
B_LMS_d2=zeros(1,Length);
B_LMS_d3=zeros(1,Length);
angle1=linspace(-pi/2,pi/2,Length);
%计算阵列流形矩阵A
for i=1:length(angle1)
Aa_d1=exp(-j*2*pi*d1*sin(angle1(i))*[0:Na-1]');
Aa_d2=exp(-j*2*pi*d2*sin(angle1(i))*[0:Na-1]');
Aa_d3=exp(-j*2*pi*d3*sin(angle1(i))*[0:Na-1]');
B_LMS_d1(i)=20*log10(abs(W_LMS_d1'*Aa_d1));
B_LMS_d2(i)=20*log10(abs(W_LMS_d2'*Aa_d2));
B_LMS_d3(i)=20*log10(abs(W_LMS_d3'*Aa_d3));
end
%波束方向图
figure()
angle2=-90:180/Length:(90-180/Length);
plot(angle2,B_LMS1);
title('波束方向图');
xlabel('方向角/degree');
ylabel('LMS幅度响应/dB');
grid on;
%波束方向圆图
figure()
angle3 = angle2*angtorad; %弧度化为度
polar(angle3,10.^(B_LMS1/20));
title('波束方向图(极坐标)');
%均方误差随迭代次数变化图
figure()
for k=1:N
enn1(k)=abs(er1(k));
enn2(k)=abs(er2(k));
end
n=1:1:N;
subplot(2,1,1);
plot(n,enn1,n,enn2,'r:');
legend('u=5e-6','u=5e-7');
title('不同步长因子下的误差');
xlabel('迭代次数N');
ylabel('LMS误差');
for k=1:N
en1(k)=(abs(er1(k)))^2/N;
en2(k)=(abs(er2(k)))^2/N;
end
n=1:1:N;
subplot(2,1,2);
semilogy(n,en1,n,en2,'r:');
legend('u=5e-6','u=5e-7');
xlabel('迭代次数N');
ylabel('LMS均方误差MSE');
hold on
csvwrite('C:\Users\lth\Documents\MATLAB\my_adaptive_singnal\LMS.txt',B_LMS1);
csvwrite('C:\Users\lth\Documents\MATLAB\my_adaptive_singnal\LMS_MES.txt',en1);
figure()
angle2=-90:180/Length:(90-180/Length);
plot(angle2,B_LMS1,'*-',angle2,B_LMS2,'ro-');
legend('u=5e-6','u=5e-7');
xlabel('方向角/degree');
ylabel('LMS幅度响应/dB');
title('不同步长因子下的波束图');
figure()
angle2=-90:180/Length:(90-180/Length);
plot(angle2,B_LMS_d1,'r*-',angle2,B_LMS_d2,'d-',angle2,B_LMS_d3,'k.-');
legend('d=0.25','d=0.5','d=1');
xlabel('方向角/degree');
ylabel('LMS幅度响应/dB');
title('不同阵元间距下的波束图');
hold on