📄 elenven.m
字号:
%
% Problem 11.2
%
clear
M = 20; % number of elements
spacing = 0.5; % lambda/2 spacing
% First part of problem has a steering angle of 45 degrees
phi_steer = 45; % steering direction
% Compute the steering vectors for electronic and mechanical steering
v_elec = exp(-j*2*pi*spacing*[0:(M-1)]'*sin(phi_steer*pi/180))/sqrt(M);
v_mech = exp(-j*2*pi*spacing*[0:(M-1)]'*sin(0*pi/180))/sqrt(M);
% Angles for beampattern
phi = -90:90;
V = exp(-j*2*pi*spacing*[0:(M-1)]'*sin(phi*pi/180))/sqrt(M);
% Compute the beampatterns for electronic and mechanical steering
V_elec = V'*v_elec;
V_mech = V'*v_mech;
% Mechanical steering angles are simply the true angles shifted by
% the mechanical steering angle
phi_mech = phi + phi_steer; % mechanical steering angles for beampattern
index_toobig = find(phi_mech > 90);
phi_mech(index_toobig) = phi_mech(index_toobig)-180;
[phi_mech,index] = sort(phi_mech);
V_mech = V_mech(index);
% Plot out the beampatterns in decibels
figure
plot(phi,20*log10(abs(V_elec)),'b',...
phi_mech,20*log10(abs(V_mech)),'r--',...
'linewidth',2.5);
xlabel('Angle (deg)','fontweight','bold','fontsize',20);
ylabel('Power Response (dB)','fontweight','bold','fontsize',20);
set(gca,'fontweight','bold','fontsize',18);
axis([-90 90 -50 0]);
grid;
set(gca,'xtick',-90:15:90);
% Repeat for a steering angle of 60 degrees
phi_steer = 60; % steering direction
% Compute the steering vectors for electronic and mechanical steering
v_elec = exp(-j*2*pi*spacing*[0:(M-1)]'*sin(phi_steer*pi/180))/sqrt(M);
v_mech = exp(-j*2*pi*spacing*[0:(M-1)]'*sin(0*pi/180))/sqrt(M);
% Angles for beampattern
phi = -90:90;
V = exp(-j*2*pi*spacing*[0:(M-1)]'*sin(phi*pi/180))/sqrt(M);
% Compute the beampatterns for electronic and mechanical steering
V_elec = V'*v_elec;
V_mech = V'*v_mech;
% Mechanical steering angles are simply the true angles shifted by
% the mechanical steering angle
phi_mech = phi + phi_steer; % mechanical steering angles for beampattern
index_toobig = find(phi_mech > 90);
phi_mech(index_toobig) = phi_mech(index_toobig)-180;
[phi_mech,index] = sort(phi_mech);
V_mech = V_mech(index);
% Plot out the beampatterns in decibels
figure
plot(phi,20*log10(abs(V_elec)),'b',...
phi_mech,20*log10(abs(V_mech)),'r--',...
'linewidth',2.5);
xlabel('Angle (deg)','fontweight','bold','fontsize',20);
ylabel('Power Response (dB)','fontweight','bold','fontsize',20);
set(gca,'fontweight','bold','fontsize',18);
axis([-90 90 -50 0]);
grid
set(gca,'xtick',-90:15:90);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -