如何在matlab中制作动画图 [英] How to do an animated plot in 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屋!