如何在Matlab中制作动画情节 [英] How to do an animated plot in matlab

查看:265
本文介绍了如何在Matlab中制作动画情节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人知道如何制作动画 x =(1000点数据集) y =(1000个点的数据集) 情节(x,y)

I was wondering if anyone knew how to do an animation plot of x = (dataset of 1000 points) y = (dataset of 1000 points) plot(x,y)

最大的问题是这些是我要绘制的数据集,即x,y坐标,而不是我会通过动画绘制的函数.

big problem is these are datasets that i am trying to plot , or x,y coordinates as opposed to a function which I would know how to plot via an animation.

我试图在for循环中制作帧,但是它给了我点,并且没有将它们加入折线图中,因此我无法真正观察到被追踪的路径.

I tried to do frames in a for loop but it gave me dots and didn't join them in a line graph so I couldn't really watch the path being traced out.

我使用的代码是

for i = 1:length(DATASET1)
pause(0.1)
plot(DATASET1(i),DATASET2(i))
draw on
end

推荐答案

看起来像你很近.不确定draw on是什么命令.

Looks like you were close. Not sure draw on is any command though.

看看这里的代码是否激发您解决问题-

See if the code here inspires you to solve your case -

%// Sample x and y values assumed for demo.
x = 1:1000;
y = x.^2;

%// Plot starts here
figure,hold on

%// Set x and y limits of the plot
xlim([min(x(:)) max(x(:))])
ylim([min(y(:)) max(y(:))])

%// Plot point by point
for k = 1:numel(x)
    plot(x(k),y(k),'-') %// Choose your own marker here

    %// MATLAB pauses for 0.001 sec before moving on to execue the next 
    %%// instruction and thus creating animation effect
    pause(0.001);     
end

这篇关于如何在Matlab中制作动画情节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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