具有θ,phi和半径的Polar(3D)图

时间:2019-03-06 19:51:33

标签: matlab 3d polar-coordinates

我想绘制一个带有极坐标参数theta,phi和radius的3D图。我已经计算出这三个参数,但无法获得3D图。

我想要一个如下图所示的图。enter image description here

我从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')

1 个答案:

答案 0 :(得分:0)

示例代码使用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)

enter image description here

当然也可以是懒惰的并且使用sph2cart(请注意,Matlab与我的角度相反):

[X,Y,Z] = sph2cart(phi,theta,r);