質問

I've run simulations which have given me data points corresponding to X number of different radii, and Y number of angles each one was evaluated at. This means that I have X times Y data points which I need to plot.

I am currently plotting it in an non-ideal fashion: I am using the x and y axes as the r and theta axes. This means that my data appears as a sinusoidal trend which increases with radius on a Cartesian grid, not the circle which it physically represents. This is how I am currently plotting my data:

surf(r_val, th_val, v_val);

What I wish to do is plot my data on a cylindrical axis, such like that of the function polar(), but in R3 space. I would rather not download a toolbox, or modify the existing polar function; if there is no other solution then I will obviously end up doing this anyways.

Thanks for your help! G.

Also, I am using Matlab 2012a

EDIT:

r_val = 1x8 vector containing unique radii

th_val = 1x16 vector containing unique angles

v_val = 8x16 matrix containing voltages corresponding to each position

NOTE: (after answered)

The truly ideal solution does not exist to this problem, as Matlab currently supports no true polar axes methods. Resource found here.

役に立ちましたか?

解決

You should transform your coordinates to Cartesian coordinates before plotting them. MATLAB has builtin functions for perfroming coordiante transformations. See, for example pol2cart, which transforms polar or cylindrical coordinates to Cartesian coordinates. In your case you would simply use something like:

[x, y] = pol2cart(th_val, r_val);

surf(x, y, v_val);

Edit: Given that th_val and r_val are vectors of differing lengths it is necessary to first create a grid of points before calling pol2cart, along the lines of:

[R, T] = meshgrid(r_val, th_val);
[x, y] = pol2cart(T, R);
surf(x, y, v_val);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top