带有 theta、phi 和半径的极坐标 (3D) 图
Polar(3D) plot with theta, phi and radius
我想用极坐标参数 theta、phi 和半径绘制 3D 图。我已经计算了这 3 个参数,但无法获得 3D 图。
我想要一个如下图所示的情节。
我从 matlab 中的 PhaseShiftBeamformerUsingULAExample 得到了这个图。我不明白他们是怎么得到这样一个阴谋的。它的 Matlab 代码如下。
%% Phase-Shift Beamformer Using ULA
% Apply phase-shift beamforming to the signal received by a 5-element ULA.
% The beamforming direction is 45° azimuth and 0° elevation. Assume
% the array operates at 300 MHz. Specify the beamforming direction using an
% input port.
%%
% Simulate a sinewave signal arriving at the array.
clearvars;close all;
t = (0:1000)';
fsignal = 0.01;
x = sin(2*pi*fsignal*t);
c = physconst('LightSpeed');
fc = 300e6;
incidentAngle = [30;15];
array = phased.ULA('NumElements',5);
x = collectPlaneWave(array,x,incidentAngle,fc,c);
noise = 0.1*(randn(size(x)) + 1j*randn(size(x)));
rx = x + noise;
%%
% Construct the phase-shift beamformer and then beamform the input data.
beamformer = phased.PhaseShiftBeamformer('SensorArray',array,...
'OperatingFrequency',fc,'PropagationSpeed',c,...
'DirectionSource','Input port','WeightsOutputPort',true);
%%
% Obtain the beamformed signal and the beamformer weights.
[y,w] = beamformer(rx,incidentAngle);
%%
% Plot the original signal at the middle element and the beamformed signal.
figure();
plot(t,real(rx(:,3)),'r:',t,real(y))
xlabel('Time')
ylabel('Amplitude')
legend('Original','Beamformed')
%%
% Plot the array response pattern after applying the weights.
figure();
pattern(array,fc,[-180:180], [-90:90],'PropagationSpeed',c,'CoordinateSystem','polar','Weights',w,'Type','efi eld')
示例代码使用the pattern command from the phased array toolbox。这对于他们的应用程序来说是非常具体的。
我只想将 theta、phi 和 r 转换为笛卡尔坐标并使用 surf 或 surfl 绘制它们:
[theta,phi]=meshgrid(linspace(-pi/2,pi/2),linspace(0,2*pi));
r=1+sin(theta*3).*cos(phi*2);
X=cos(theta).*cos(phi).*r;
Y=cos(theta).*sin(phi).*r;
Z=sin(theta).*r;
surf(X,Y,Z)
当然也可以偷懒,使用 sph2cart(注意 Matlab 的角度符号与我相反):
[X,Y,Z] = sph2cart(phi,theta,r);
我想用极坐标参数 theta、phi 和半径绘制 3D 图。我已经计算了这 3 个参数,但无法获得 3D 图。
我想要一个如下图所示的情节。
我从 matlab 中的 PhaseShiftBeamformerUsingULAExample 得到了这个图。我不明白他们是怎么得到这样一个阴谋的。它的 Matlab 代码如下。
%% Phase-Shift Beamformer Using ULA
% Apply phase-shift beamforming to the signal received by a 5-element ULA.
% The beamforming direction is 45° azimuth and 0° elevation. Assume
% the array operates at 300 MHz. Specify the beamforming direction using an
% input port.
%%
% Simulate a sinewave signal arriving at the array.
clearvars;close all;
t = (0:1000)';
fsignal = 0.01;
x = sin(2*pi*fsignal*t);
c = physconst('LightSpeed');
fc = 300e6;
incidentAngle = [30;15];
array = phased.ULA('NumElements',5);
x = collectPlaneWave(array,x,incidentAngle,fc,c);
noise = 0.1*(randn(size(x)) + 1j*randn(size(x)));
rx = x + noise;
%%
% Construct the phase-shift beamformer and then beamform the input data.
beamformer = phased.PhaseShiftBeamformer('SensorArray',array,...
'OperatingFrequency',fc,'PropagationSpeed',c,...
'DirectionSource','Input port','WeightsOutputPort',true);
%%
% Obtain the beamformed signal and the beamformer weights.
[y,w] = beamformer(rx,incidentAngle);
%%
% Plot the original signal at the middle element and the beamformed signal.
figure();
plot(t,real(rx(:,3)),'r:',t,real(y))
xlabel('Time')
ylabel('Amplitude')
legend('Original','Beamformed')
%%
% Plot the array response pattern after applying the weights.
figure();
pattern(array,fc,[-180:180], [-90:90],'PropagationSpeed',c,'CoordinateSystem','polar','Weights',w,'Type','efi eld')
示例代码使用the pattern command from the phased array toolbox。这对于他们的应用程序来说是非常具体的。
我只想将 theta、phi 和 r 转换为笛卡尔坐标并使用 surf 或 surfl 绘制它们:
[theta,phi]=meshgrid(linspace(-pi/2,pi/2),linspace(0,2*pi));
r=1+sin(theta*3).*cos(phi*2);
X=cos(theta).*cos(phi).*r;
Y=cos(theta).*sin(phi).*r;
Z=sin(theta).*r;
surf(X,Y,Z)
当然也可以偷懒,使用 sph2cart(注意 Matlab 的角度符号与我相反):
[X,Y,Z] = sph2cart(phi,theta,r);