is it possible to add a 3D sphere marker to a 2D plot?

5 次查看(过去 30 天)
is there an easy way to do this? would it be possible to use the sphere command? its part of a movie so don't know how feasible using the sphere command would be.
  2 个评论
dpb
dpb 2018-8-7
sphere will create a 3D axis; you would have to somehow overlay it on the 2D one which would mean orienting it to only show the xy plane which reduces the appearance of the sphere to a circle since it's a projection onto the surface....
Adam
Adam 2018-8-7
The fact you have a 2D plot is largely irrelevant to plotting a sphere apart from the issue of getting it in the right place, it being visible and as dpb says, if it is only viewed in 2d then it is just a circle anyway.
You can plot anything you want together on a set of axes though if you use hold on to avoid replacing the other things on the axes.
When you plot an image it is still on a 3d axes, just with an X-Y projection. If you click the rotate icon on the toolbar you will soon end up with a 3d view where your image is just a plane through it.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2018-8-7
Try this:
[Xs,Ys,Zs] = sphere;
figure
for k1 = 1:0.03:3.2
Xp = Xs + cos(k1*2*pi);
Yp = Ys + sin(k1*2*pi);
surf(Xp, Yp, Zs)
axis([-3 3 -3 3 -3 3])
% axis equal
view(0,90)
grid on
refreshdata
drawnow update
end
hold off
Experiment to get the result you want.

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by