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

조회 수: 8 (최근 30일)
james Brown
james Brown 2018년 8월 7일
답변: Star Strider 2018년 8월 7일
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