Can somebody help me how can I draw a hemisphere with flat top?
3 views (last 30 days)
Show older comments
0 Comments
Answers (1)
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)
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.
.
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!