Can somebody help me how can I draw a hemisphere with flat top?

2 views (last 30 days)
Mohammad Hasan Asghari
Mohammad Hasan Asghari on 22 Jun 2022
Answered: Star Strider on 22 Jun 2022

Answers (1)

Star Strider
Star Strider on 22 Jun 2022
One approach —
[X,Y,Z] = sphere(20);
figure
surf(X, Y, Z)
axis('equal')
grid on
title('Original Sphere')
Top = 0.85;
Ztop = interp1(Z(:,1), (1:size(Z,1)), Top)
Ztop = 17.4999
Lm = Z<=0 | Z>=Top; % Logical Matrix
Z(Lm) = NaN;
C = [0.7 0.5 0.5];
figure
surf(X, Y, Z, 'FaceColor',C, 'EdgeColor','none')
hold on
patch(X(17,:), Y(17,:), Z(17,:), C)
hold off
lightangle(gca,85,80)
lighting gouraud
axis('equal')
grid on
title('Truncated Sphere')
view(27,15)
Make appropriate changes to get the desired result.
.

Tags

Community Treasure Hunt

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

Start Hunting!