How to draw a ball by plot3?
Mostrar comentarios más antiguos
I am learning the MATLAB,
Respuesta aceptada
Más respuestas (2)
m = 100; n = 100; p = 100 ;
[X,Y,Z] = ndgrid(-m:m,-n:n,-p:p) ;
x = X(:) ;
y = Y(:) ;
z = Z(:) ;
r = sqrt(x.^2+y.^2+z.^2) ;
idx = r <= 10 ;
plot3(x(idx),y(idx),z(idx),'.r')
axis equal
3 comentarios
Xizeng Feng
el 19 de Feb. de 2022
KSSV
el 19 de Feb. de 2022
How you want to look like? What's your expectations?
Xizeng Feng
el 19 de Feb. de 2022
like this? but it doesn't use plot3
[x,y,z] = sphere(64);
p = surf(x,y,z,"FaceColor","interp","EdgeColor","none");
p.CData = rand(size(p.ZData));
colormap gray
axis equal
lighting phong
camorbit(60,0)
axis off
Categorías
Más información sobre Surface and Mesh Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



