How to create a Cap Sphere .

Hi all,
I would like to plot a cap sphere with matlab so, How to write this code. Please help me !
Thanks in advand!

回答 (1 件)

Image Analyst
Image Analyst 2014 年 10 月 5 日

0 投票

Do you mean like this:
workspace
R = 2;
[x,y,z] = sphere;
% Define rows to keep as those with Z in the middle
topCap = z > .5;
bottomCap = z < -.5;
% Max out z at the cap values where x and y are in the cap.
z(topCap) = 0.5;
z(bottomCap) = -0.5;
% Display it.
surf(R*x, R*y, R*z);
axis equal

2 件のコメント

Quaan Nguyeen
Quaan Nguyeen 2014 年 10 月 6 日
Thanks for your help!
But I would like to use the coordinate of sphere to write it: That is
Please help me with this question again, How to write it by matlab using above fomular :D Thank alot!
Image Analyst
Image Analyst 2014 年 10 月 6 日
I don't think that's a MATLAB question. But if you get x, y, and z, by using for loops over phi and theta, then simply do what I did to clip the z values to some cap values:
% Max out z at the cap values where x and y are in the cap.
z(topCap) = 0.5;
z(bottomCap) = -0.5;

サインインしてコメントする。

カテゴリ

質問済み:

2014 年 10 月 5 日

コメント済み:

2014 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by