plotting a sphere using isonormal

조회 수: 18 (최근 30일)
Oanh Nguyen
Oanh Nguyen 2015년 11월 22일
답변: Anudeep Kumar 2025년 3월 10일
How can you plot a 3D sphere using the command "isonormals" with a color of my choice? Thanks!!!! Any help would be appreciated.

답변 (1개)

Anudeep Kumar
Anudeep Kumar 2025년 3월 10일
Hello Oanh,
Below is the code that produces a 3D sphere using isonormals:
% Define the grid
[x, y, z] = meshgrid(linspace(-1, 1, 50));
% Define the equation of the sphere
v = x.^2 + y.^2 + z.^2;
% Create the figure
figure;
% Plot the isosurface for the sphere
h = patch(isosurface(x, y, z, v, 1));
% Apply isonormals to improve the rendering
isonormals(x, y, z, v, h);
% Set the color of the sphere
% Replace [0.5, 0.5, 0.8] with your desired RGB color
h.FaceColor = [0.5, 0.5, 0.8];
h.EdgeColor = 'none';
% Adjust lighting and view for better visualization
camlight;
lighting gouraud;
axis equal;
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('3D Sphere with Isonormals');
Here is the link for isnormals() function for your reference:
I hope this works!

카테고리

Help CenterFile Exchange에서 Volume Visualization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by