简体   繁体   English

Matlab 3D极坐标图

[英]Matlab 3D polar plot

I am struggling with the concepts behind plotting a surface polar plot. 我正在努力绘制表面极坐标图的概念。

I am trying to plot the values measured by a sensor at a combination of different angles over a hemisphere. 我正在尝试绘制传感器在半球上不同角度的组合所测得的值。

I have an array containing the following information: 我有一个包含以下信息的数组:

A(:,1) = azimuth values from 0 to 360º A(:,1)= 0至360º的方位角值

A(:,2) = zenith values from 0 to 90º A(:,2)=从0到90º的天顶值

A(:,3) = values measured at the combination of angles of A(:,1) and A(:,2) A(:,3)=以A(:,1)和A(:,2)的角度组合测得的值

For example, here is a snippet: 例如,这是一个片段:

0   15  0.489502132167206
0   30  0.452957556748497
0   45  0.468147850273115
0   60  0.471115818950192
0   65  0.352532182508945
30  15  0.424997863795610
30  30  0.477814980942155
30  45  0.383999653859467
30  60  0.509625464595446
30  75  0.440940431784788
60  15  0.445028058361392
60  30  0.522388502880219
60  45  0.428092266657885
60  60  0.429315072676194
60  75  0.358172892912138
90  15  0.493704001125912
90  30  0.508762762699997
90  45  0.450598496609200
90  58  0.468523071441297
120 15  0.501619699042408
120 30  0.561755273071577
120 45  0.489660355057938
120 60  0.475478615354648
120 75  0.482572226928475
150 15  0.423716506205776
150 30  0.426735372570756
150 45  0.448548968227972
150 60  0.478055144126694
150 75  0.437389584937356

To clarify, here is a piece of code that shows the measurement points on a polar plot. 为了澄清起见,这是一段代码,显示极坐标图上的测量点。

th = A(:,1)*pi/180

polar(th,A(:,2))
view([180 90])

This gives me the following plot: 这给了我以下情节:

例

I would like now to plot the same thing, but instead of the points, use the values of these points stored in A(:,3). 我现在想绘制相同的图,但是要使用这些点的值而不是点,这些值存储在A(:,3)中。 Then, I would like to interpolate the data to get a colored surface. 然后,我想对数据进行插值以获得有色表面。

After some research, I found that I need to interpolate my values over a grid, then translate to Cartesian coordinates. 经过研究,我发现我需要在网格上插值,然后转换为笛卡尔坐标。 From there I do not know how to proceed. 从那里我不知道如何进行。 Could someone point me in the right direction? 有人可以指出我正确的方向吗?

I have trouble getting the concept of the interpolation, but this is what I have attempted: 我很难理解插值的概念,但这是我尝试的方法:

x1 = linspace(0,2*pi,100)

x2 = linspace(0,90,100)

[XX,YY] = meshgrid(x1,x2) 

[x,y] = pol2cart(th,A(:,2)) 

gr=griddata(x,y,A(:,3),XX,YY,'linear') 

With this piece of code, your example data points are converted into cartesian coords, and then plotted as "lines". 使用这段代码,您的示例数据点将转换为笛卡尔坐标,然后绘制为“线”。 The two tips of a line are one data point and the origin. 一条线的两个提示是一个数据点和原点。

az = bsxfun(@times, A(:,1), pi/180);
el = bsxfun(@times, A(:,2), pi/180);
r = A(:,3);

[x,y,z] = sph2cart(az,el,r);
cx = 0; % center of the sphere
cy = 0;
cz = 0;
X = [repmat(cx,1,length(x));x'];
Y = [repmat(cy,1,length(y));y'];
Z = [repmat(cz,1,length(z));z'];

Still thinking how to interpolate the data so you can draw a sphere. 仍在思考如何对数据进行插值,以便绘制一个球体。 See my comments to your question. 查看我对您问题的评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM