analytic solution with infinite sum
3 views (last 30 days)
Show older comments
Hi,
I am having trouble figuring out how to write the code for this function that contains an infinite series.
Ti = 150;
T1 = 300;
T2 = 200;
L = 1;
alpha = 0.1;
delta_x = 0.05;
delta_t = 0.01;
N_time = 51;
N_space = 21;
x = linspace(0,L,N_space);
t = linspace(0,0.5,N_time);
I need to make the code so that it can compute this:
% I also need a little help in making the function. I have used syms m x t, but it doesn't work all the time.
c_m = (2/m*pi) ((Ti - T1)-(-1)^m*(Ti - T2))
T(x,t) = T1 + (T2 - T1)*(x/L) + %my unknown part: the infinite sum starting from 1 of c_n*exp(-m^2*pi^2*alpha*t/L^2)*sin(m*pi*x/L)
3 Comments
Answers (1)
darova
on 23 Feb 2020
Here is my attempt
Ti = 150;
T1 = 300;
T2 = 200;
L = 1;
alpha = 0.1;
delta_x = 0.05;
delta_t = 0.01;
N_time = 51;
N_space = 21;
x = linspace(0,L,N_space);
t = linspace(0,0.5,N_time);
[X,T] = meshgrid(x,t);
cm = X*0;
for m = 1:100
C1 = 2/m/pi*( (Ti-T1)-(-1)^m*(Ti-T2) );
C2 = exp(-m^2*pi^2*alpha*T/L^2).*sin(m*pi*X/L);
cm = cm + C1*C2;
end
surf(X,T,cm)
xlabel('X')
ylabel('T')
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!