is it possible to add a 3D sphere marker to a 2D plot?
8 次查看(过去 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
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
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!