MATLAB:循环绘制 [英] MATLAB: plot in a loop

查看:56
本文介绍了MATLAB:循环绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在循环内进行绘图,并且只打印最后一个绘图.

I've tried to do plot inside of a loop and it prints only the last plot.

我该如何解决?

在图定义之后,我尝试使用保持 drawnow ,但是它不起作用.

I've tried to use hold on and drawnow after the plot definition but it didn't work.

这是我的代码:

for t=1:5
  alive = Game(World , Generations, speed);
  plot(hplot2,1:Generations,alive);
end

推荐答案

按住应该可以.试试这个:

hold on should work. Try this:

figure
hplot2=gca;
hold on
for t=1:5
    alive = rand(1,Generations);
    plot(hplot2,1:Generations,alive);
end

这篇关于MATLAB:循环绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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