How to hold a plot when using plot3 in matlab?

可紊 提交于 2019-11-28 01:46:35

问题


This works as I expected:

    for i=1:100
      hold on;
      plot(i,i^2);
      drawnow;
    end

Ploting the points as they come in the same figure.

This on the other hand, doesn't:

    for i=1:100
      hold on;
      plot3(i,i^2,sqrt(i));
      drawnow;
    end;

Since it does not show a 3d plot of the points, it only shows the projection of them in the xy plane. Somehow the hold onstatement messes up with plot3.

How can I obtain results that are analogous to the 2d case when using plot, in the 3d case, when I have points in several 3d locations?

I've tried to make this question concise, if you believe I haven't explained it well enough for a satisfactory answer please say so in the comments.


回答1:


Your code correctly plots a 3-D curve. All you need to do to see it is add

view(3);

anywhere in your code.

Additionally, one hold on command is sufficient (i.e. you don't need to repeat it in every loop iteration).



来源:https://stackoverflow.com/questions/16290687/how-to-hold-a-plot-when-using-plot3-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!