필터 지우기
필터 지우기

Surface plot error for Z must be a matrix, not a scalar or vector

조회 수: 1 (최근 30일)
Hu1k
Hu1k 2021년 9월 27일
편집: Walter Roberson 2021년 9월 28일
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

답변 (2개)

Walter Roberson
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.
  댓글 수: 1
Hu1k
Hu1k 2021년 9월 27일
So should I change x to 1d or input phi as a matrix. And could you tell me how I should change that?

댓글을 달려면 로그인하십시오.


Matt J
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
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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by