- #1
Moly
- 21
- 0
Compared to the questions out there, my question seems VERY SIMPLE.
I have a code that generates a few graphs. Instead of super-imposing the graphs on one figure, I would like MATLAB to generate an animation of those graphs for me. I tried looking at help and my intution tells me that getframe is the way to go, but my technical capablities do not extend that far.
Any suggestion on how i can animate these figures? Here is my code
x0=0; xt=30; dt=.1;
L=(xt-x0)/dt+1;
n=10;
for k=1:6
t=5*k;
for i=1:L
summ=0;
x(i)=x0+(i-1)*dt;
for j=1:n
npi=j*pi;
a=2*(1-cos(npi))-npi^2*(1+cos(npi));
b= exp((-npi^2*t)/900);
c=sin(npi*x(i)/30);
summ=summ+((a-b)/j^3)*b*c;
end
u(i)=30-x(i)+(60/pi^3)*summ;
end
plot(x,u); hold on
end
title(' u(x,t) vs x for several values of t')
I have a code that generates a few graphs. Instead of super-imposing the graphs on one figure, I would like MATLAB to generate an animation of those graphs for me. I tried looking at help and my intution tells me that getframe is the way to go, but my technical capablities do not extend that far.
Any suggestion on how i can animate these figures? Here is my code
x0=0; xt=30; dt=.1;
L=(xt-x0)/dt+1;
n=10;
for k=1:6
t=5*k;
for i=1:L
summ=0;
x(i)=x0+(i-1)*dt;
for j=1:n
npi=j*pi;
a=2*(1-cos(npi))-npi^2*(1+cos(npi));
b= exp((-npi^2*t)/900);
c=sin(npi*x(i)/30);
summ=summ+((a-b)/j^3)*b*c;
end
u(i)=30-x(i)+(60/pi^3)*summ;
end
plot(x,u); hold on
end
title(' u(x,t) vs x for several values of t')