필터 지우기
필터 지우기

Plotting 3d sphere from equation

조회 수: 5 (최근 30일)
Khanh
Khanh 2011년 11월 16일
I'm looking for a way to plot a 3d sphere given its equation.
Eg: (x-a)^2 + (y-b)^2 + (z-c)^2 <= R
I found that 'sphere' allows me to plot a unit sphere and that I can change its center using 'surf'. However, I don't see anyway to change the radius.
I haven't tried 'sphere3d', but from its documentation, it looks like I have to convert my equation to the polar coordinate system.
Is there any other function in matlab that can plot a sphere given an equation like above?
Thanks,

채택된 답변

Khanh
Khanh 2011년 11월 16일
Another way I can think of is using 'ellipsoid'. It will be like this:
[x,y,z] = ellipsoid(a,b,c,R,R,R);
surf(x,y,z);
Another way, I can do with 'sphere' is to scale the the surface like this:
[x,y,z] = sphere;
surf(R*x, R*y, R*z);

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 16일
To change the radius of sphere(), multiply all of its coordinates by R (before doing any translation.)
  댓글 수: 2
Khanh
Khanh 2011년 11월 17일
Thanks Walter. I think that's what I mentioned above with surf(R*x, R*y, R*z), right?
Walter Roberson
Walter Roberson 2011년 11월 17일
Yup.

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

카테고리

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