How to plot such a complete figure by matlab. The hemisphere is $x^2+y62+z^2=4$ and the cylinder is $x^2+y^2=1$ with bases $z=0$ and $z=\sqrt{3}$

7 ビュー (過去 30 日間)
How to plot such a complete figure by matlab. The hemisphere is $x^2+y62+z^2=4$ and the cylinder is $x^2+y^2=1$ with bases $z=0$ and $z=\sqrt{3}$
The code of hemisphere
R = 2;
[X,Y] = meshgrid(-2:.1:2);
Z = sqrt(R.^2 - X.^2 - Y.^2);
Z(imag(Z) ~= 0) = 0;
mesh(X,Y,Z);
  2 件のコメント
Jeffrey Clark
Jeffrey Clark 2022 年 6 月 5 日
You can use the sphere (scaled by 4) and cylinder and limit what is shown in the yellow area by finding intersect of cylinder and sphere z value: z^2 = 4 - (x^2 + y^2) and from cylinder x^2 + y^2 = 1 therefore min z^2 = 4 - 1 and max z^2 = 4. Just draw sphere points where z in [ sqrt(3) .. 2 ].
Jeffrey Clark
Jeffrey Clark 2022 年 6 月 7 日
@Atom let me know if I missed your real question.

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

採用された回答

KSSV
KSSV 2022 年 6 月 7 日
I would go by parametric equations.
%% Sphere
R = 2 ;
th = linspace(0,2*pi) ;
phi = linspace(0,pi/2) ;
[T,P] = meshgrid(th,phi) ;
X1 = R*cos(T).*sin(P) ;
Y1 = R*sin(T).*sin(P) ;
Z1 = R*cos(P) ;
%% Cyclinder
R = 1 ;
H = sqrt(3) ;
th = linspace(0,2*pi);
h = linspace(0,H) ;
[T,H] = meshgrid(th,h) ;
X2 = R*cos(T);
Y2 = R*sin(T) ;
Z2 = H ;
mesh(X1,Y1,Z1,'FaceAlpha',0.5)
hold on
mesh(X2,Y2,Z2)
axis equal
  1 件のコメント
Atom
Atom 2022 年 6 月 9 日
Thanks...How to make the region of intersection S by a different colour (like the above fig)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by