how could i animate this?

x=linspace(-5,5,1000);
a_n=2;
b_n=3;
l=10;
for n=1:1:10
for t=0:1:10
y=a_n*cos((n*pi*t)/l)+b_n*sin((n*pi*t)/l)*sin((n*pi*x)/l);
end
end
u=y;
plot(x,u)

3 个评论

Jan
Jan 2018-12-17
编辑:Jan 2018-12-17
Hard to guess. What should be animated? Perhaps all you want to dois to move the plot command into the loops and add a pause(0.1) command.
that is right!
you need to know that there are several curves created in each loop iteration but you overwrite all the values and only the end values are saved in the last iteration

请先登录,再进行评论。

 采纳的回答

KSSV
KSSV 2018-12-18
编辑:KSSV 2018-12-18
comet(x,u)
OR
x=linspace(-5,5,1000);
a_n=2;
b_n=3;
l=10;
for n=1:1:10
for t=0:1:10
y=a_n*cos((n*pi*t)/l)+b_n*sin((n*pi*t)/l)*sin((n*pi*x)/l);
plot(x,y)
pause(0.1)
end
end

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Animation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by