MATLAB Answers

how could i animate this?

1 view (last 30 days)
HADIMARGO
HADIMARGO on 17 Dec 2018
Commented: madhan ravi on 18 Dec 2018
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 Comments

Jan
Jan on 17 Dec 2018
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.
HADIMARGO
HADIMARGO on 17 Dec 2018
that is right!
madhan ravi
madhan ravi on 18 Dec 2018
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

Sign in to comment.

Accepted Answer

KSSV
KSSV on 18 Dec 2018
Edited: KSSV on 18 Dec 2018
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 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags