35 views (last 30 days)

Show older comments

function polar3D(theta,phi,f)

f = abs(f);

f = f/max(max(f));

[x,y,z] = sph2cart(f,theta,phi);

[N,M] = size(x);

color = ones(N,M);

surf(x,y,z,color);

Just don't know how to make z a matrix after sph2cart

Walter Roberson
on 27 Sep 2021 at 21:43

careful, x is (eventually) going to be 3d, and the way you use size is wrong for 3d.

I have seen cases where z was returned as an unexpected number of dimensions when phi was scalar.

Matt J
on 27 Sep 2021 at 22:07

Edited: Matt J
on 27 Sep 2021 at 22:27

Just don't know how to make z a matrix after sph2cart

z will be a matrix if at least one of the inputs f, theta and phi are matrices. This should be the case, otherwise you haven't generated samples that cover a 2D surface.

Walter Roberson
on 28 Sep 2021 at 3:30

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!