Surface plot error for Z must be a matrix, not a scalar or vector
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(2 个)
Walter Roberson
2021-9-27
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
2021-9-27
编辑:Matt J
2021-9-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.
1 个评论
Walter Roberson
2021-9-28
编辑:Walter Roberson
2021-9-28
I have seen x, y come out 2d but z come out vector. But I have also seen z come out as matrix. I did not track down the conditions
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!