plotting a sphere using isonormal

18 次查看(过去 30 天)
Oanh Nguyen
Oanh Nguyen 2015-11-22
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