Borrar filtros
Borrar filtros

Plotting a Sum of Series

1 visualización (últimos 30 días)
Ítalo Barros
Ítalo Barros el 2 de Dic. de 2017
Respondida: Vidya Bhadgaonkar el 10 de Oct. de 2019
I have to plot these equations about the heat in a aluminium bar:
But for some reason, my graph of u(x,t)(in this case u on the code) is showing something different (i think the correct would be a exponential). Can someone review my code and see if is there any mistakes? Obs: n is the value where sin=0, for example sin(n*pi)=0 like in pi, 2pi, 3pi...
clc
clear all
syms x k t n
for n=1:1:20
cn=(100/(n*pi))*(cos(pi*x/4)-cos(3*pi*x/4));
for t=0:5
num=(cos(pi*x/4)-cos(3*pi*x/4));
t1=exp((-(k^2)*(pi^2)*t)/1600);
t2=sin(k*pi*x/40);
S1=symsum((num*t1*t2),k,1,inf);
u=((100/pi)*S1);
end
end
fplot(cn)
figure
fplot(u)
  1 comentario
David Goodmanson
David Goodmanson el 2 de Dic. de 2017
Hi Italo,
One thing for sure, the integral in the top equation is incorrect. I believe it should be
(100/(n*pi))*( cos(n*pi/4) - cos(3*n*pi/4) )
and a sign of something wrong was that the c_n can't depend on x.
Could you state the actual problem, in particular the length of the bar?

Iniciar sesión para comentar.

Respuestas (2)

Roger Stafford
Roger Stafford el 2 de Dic. de 2017
You have forgotten to divide by k in calculating 'u' within your for-loop. You should have:
S1=symsum((num/k*t1*t2),k,1,inf);
  1 comentario
Ítalo Barros
Ítalo Barros el 2 de Dic. de 2017
Tkx for the answer! But, even putting the 'k', the result is really strange:

Iniciar sesión para comentar.


Vidya Bhadgaonkar
Vidya Bhadgaonkar el 10 de Oct. de 2019
I think you have one mistake in
t1=exp((-(k^2)*(pi^2)*t)/1600);
write it as
t1=exp((-(n^2)*(pi^2)*t)/1600);

Categorías

Más información sobre Thermal Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by