在Matlab中使用plot3时如何保存图? [英] How to hold a plot when using plot3 in matlab?

查看:405
本文介绍了在Matlab中使用plot3时如何保存图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这按我预期的那样工作:

This works as I expected:

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

在同一图中绘制点.

另一方面,这不是:

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

由于它没有显示这些点的3d图,因此只显示了它们在xy平面上的投影. hold on声明以某种方式弄乱了plot3.

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.

在3d情况下,当我在多个3d位置有点时,如何获得类似于2d情况的结果?

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.

推荐答案

您的代码正确绘制了3D曲线.您需要做的就是添加

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

view(3);

您代码中的任何位置.

anywhere in your code.

另外,一个hold on命令就足够了(即,您不需要在每次循环迭代中都重复该命令).

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

这篇关于在Matlab中使用plot3时如何保存图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆