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 Center および File ExchangeVolume Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by