%% 例11.5 阵元域最大白噪声增益波束响应
clear all;
% kr=0.1:.1:8;
% Lk=length(kr);
% M=16;%阵元数为16
% m=1:1:M;%各阵元序号
% theta=2*pi/M*(m-1);%各阵元方位
% Nmax=20;
% N=-Nmax:1:Nmax;
% LN=length(N);
% thetas=(-180:180)/180*pi;%观察方向
% Lt=length(thetas);
% for q=1:Lk
% for p=1:Lt
% P1=0;
% P2=0;
% for n=1:LN
% Pn_open=Cn_open(N(n),kr(q))*exp(-1i*N(n)*thetas(p));
% Pn_baff=Cn_baff(N(n),kr(q))*exp(-1i*N(n)*thetas(p));
% P1=Pn_open*exp(1i*N(n)*theta)+P1;
% P2=Pn_baff*exp(1i*N(n)*theta)+P2;
% end
% p_open(p,:)=P1;
% p_baff(p,:)=P2;
% end
% p_ref_baff=p_baff((Lt-1)/2+1,:);
% p_ref_open=p_open((Lt-1)/2+1,:);
% for u=1:Lt
% B_open(u,q)=conj(p_open(u,:)/(p_open(u,:)*(p_open(u,:)')))*(p_ref_open.');
% B_baff(u,q)=conj(p_baff(u,:)/(p_baff(u,:)*(p_baff(u,:)')))*(p_ref_baff.');
% G_open(u,q)=p_open(u,:)*(p_open(u,:)');
% G_baff(u,q)=p_baff(u,:)*(p_baff(u,:)');
% end
% end
% figure;
% [THETA,Z]=meshgrid(thetas,kr);
% [X,Y,Z]=pol2cart(THETA,abs(B_open).',Z);
% mesh(X,Y,Z);zlabel('kr');title('open')
% figure;
% [THETA,Z]=meshgrid(thetas,kr);
% [X,Y,Z]=pol2cart(THETA,abs(B_baff).',Z);
% mesh(X,Y,Z);zlabel('kr');title('baff')
% figure;
% imagesc(kr,thetas*180/pi,20*log10(abs(B_open)));
% xlabel('kr');ylabel('θ/°');title('open');
% figure;
% imagesc(kr,theta*180/pi,20*log10(abs(B_baff)));
% xlabel('kr');ylabel('θ/°');title('baff');
% figure;
% plot(kr,10*log10(G_open(180,:)),'--');hold on;
% plot(kr,10*log10(G_baff(180,:)))
% grid on
% axis([0.1 8 10 15.2]);
% xlabel('kr');ylabel('10logG');legend('open','baff');
%% 圆谐波域波束形成
%% 相位模式波束形成
Nmax=100;
N=-Nmax:Nmax;
Ln=2*Nmax+1;
kr=40:70;
Lk=length(kr);
thetas=(-180:180)/180*pi;
Lt=length(thetas);
theta=-90*pi/180;
for p=1:Lk
for q=1:Lt
for u=1:Ln
W0_open(u)=1/Ln*exp(-1i*N(u)*thetas(q))/conj(Cn_open(N(u),kr(p)));
P_ref_open(u)=Cn_open(N(u),kr(p))*exp(-1i*N(u)*theta);
W0_baff(u)=1/Ln*exp(-1i*N(u)*thetas(q))/conj(Cn_baff(N(u),kr(p)));
P_ref_baff(u)=Cn_open(N(u),kr(p))*exp(-1i*N(u)*theta);
end
W_open(q,:)=W0_open;
W_baff(q,:)=W0_baff;
end
B_open(p,:)=P_ref_open*(W_open');
B_baff(p,:)=P_ref_baff*(W_baff');
end
% figure;
% imagesc(theta,kr,20*log10(abs(B_open)));
% xlabel('theta/°');ylabel('kr');title('N=15,open');
% figure;
% imagesc(theta,kr,20*log10(abs(B_baff)));
% xlabel('theta/°');ylabel('kr');title('N=15,baff');
figure;
[THETA,Z]=meshgrid(thetas,kr);
[X,Y,Z]=pol2cart(THETA,abs(B_baff),Z);
mesh(X,Y,Z);zlabel('kr');title('baff')
figure;
[THETA,Z]=meshgrid(thetas,kr);
[X,Y,Z]=pol2cart(THETA,abs(B_open),Z);
mesh(X,Y,Z);zlabel('kr');title('open')
%% 例11.7白噪声增益
% M=16;
% Nmax=[1:7];%用50代替无穷
% thetas=0*pi/180;
% kr=0.1:0.1:7;
% Lk=length(kr);
% for p=1:length(Nmax)
% N=-Nmax(p):Nmax(p);
% Ln=2*Nmax(p)+1;
% for q=1:Lk
% for n=1:Ln
% W_open(n)=1/Ln*exp(-1i*N(n)*thetas)/conj(Cn_open(N(n),kr(q)));
% W_baff(n)=1/Ln*exp(-1i*N(n)*thetas)/conj(Cn_baff(N(n),kr(q)));
% end
% G_open(p,q)=M/(W_open*(W_open'));
% G_baff(p,q)=M/(W_baff*(W_baff'));
% end
% end
% figure;
% plot(kr,10*log10(G_open(1,:)),kr,10*log10(G_open(2,:)),kr,10*log10(G_open(3,:)),...
% kr,10*log10(G_open(4,:)),kr,10*log10(G_open(5,:)),kr,10*log10(G_open(6,:)),...
% kr,10*log10(G_open(7,:)),kr,10*log10(M)*ones(1,Lk),'--')
% axis([1 7 -80 20])
% legend('N=1','N=2','N=3','N=4','N=5','N=6','N=7','Gmax');
% xlabel('kr');ylabel('10logG');title('open');
% figure;
% plot(kr,10*log10(G_baff(1,:)),kr,10*log10(G_baff(2,:)),kr,10*log10(G_baff(3,:)),...
% kr,10*log10(G_baff(4,:)),kr,10*log10(G_baff(5,:)),kr,10*log10(G_baff(6,:)),...
% kr,10*log10(G_baff(7,:)),kr,10*log10(M)*ones(1,Lk),'--')
% axis([1 7 -80 20])
% legend('N=1','N=2','N=3','N=4','N=5','N=6','N=7','Gmax');
% xlabel('kr');ylabel('10logG');title('baff');
%% 圆模态域时延求和波束形成
M=16;
Nmax=[1:10 50];
theta0=0*pi/180;
kr=.1:.1:10;
Lk=length(kr);
thetas=(-180:180)*pi/180;
Lt=length(thetas);
for p=1:length(Nmax)
N=-Nmax(p):Nmax(p);
Ln=2*Nmax(p)+1;
for q=1:Lk
for u=1:Lt
B0_open=0;
B0_baff=0;
for n=1:Ln
B0=abs(Cn_open(N(n),kr(q))).^2*exp(-1i*N(n)*(thetas(u)-theta0));
B1=abs(Cn_baff(N(n),kr(q))).^2*exp(-1i*N(n)*(thetas(u)-theta0));
B0_open=B0_open+B0;
B0_baff=B0_baff+B1;
end
B_open(u,q)=B0_open;
B_baff(u,q)=B0_baff;
end
end
BS_open(:,:,p)=B_open;
BS_baff(:,:,p)=B_baff;
end
figure;
subplot(3,2,1);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_open(:,:,1))));
xlabel('kr');ylabel('theta/°');title('N=1,open');
subplot(3,2,2);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_open(:,:,3))));
xlabel('kr');ylabel('theta/°');title('N=3,open');
subplot(3,2,3);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_open(:,:,5))));
xlabel('kr');ylabel('theta/°');title('N=5,open');
subplot(3,2,4);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_open(:,:,7))));
xlabel('kr');ylabel('theta/°');title('N=7,open');
subplot(3,2,5);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_open(:,:,10))));
figure;
subplot(3,2,1);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_baff(:,:,1))));
xlabel('kr');ylabel('theta/°');title('N=1,baff');
subplot(3,2,2);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_baff(:,:,3))));
xlabel('kr');ylabel('theta/°');title('N=3,baff');
subplot(3,2,3);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_baff(:,:,5))));
xlabel('kr');ylabel('theta/°');title('N=5,baff');
subplot(3,2,4);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_baff(:,:,7))));
xlabel('kr');ylabel('theta/°');title('N=7,baff');
subplot(3,2,5);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_baff(:,:,10))));
xlabel('kr');ylabel('theta/°');title('N=10,baff');
subplot(3,2,6);
imagesc(kr,thetas*180/pi,20*log10(abs(BS_baff(:,:,11))));
xlabel('kr');ylabel('theta/°');title('N=∞,baff');
figure;
[THETA,Z]=meshgrid(thetas,kr);
[X,Y,Z]=pol2cart(THETA,abs(BS_open(:,:,10)).',Z);
mesh(X,Y,Z);zlabel('kr');title('open K=10')
axis([-1 1 -1 1 0 10])
figure;
[THETA,Z]=meshgrid(thetas,kr);
[X,Y,Z]=pol2cart(THETA,abs(BS_baff(:,:,10)).',Z);
mesh(X,Y,Z);zlabel('kr');title('baff K=10')
axis([-2 2 -2 2 0 10])
figure;
polarplot(thetas,abs(BS_open(:,70,1)).')
hold on;polarplot(thetas,abs(BS_open(:,70,3)).')
hold on;polarplot(thetas,abs(BS_open(:,70,5)).');
hold on;polarplot(thetas,abs(BS_open(:,70,7)).');
hold on;polarplot(thetas,abs(BS_open(:,70,10)).');
hold on;polarplot(thetas,abs(BS_open(:,70,11)).');
rlim([0 1]);