# MATLAB tutorial 2.6: Boundary Value Problems for Heat Equation

Boundary Value Problems for Heat Equation

syms x n t
y1 = (x.*(120-x).*sin((n.*pi.*x)./60));
I1 = int(y1,x,0,60);
Cn = ((1/30).*I1);
utemp =
subs(Cn.*sin(n.*pi.*x.*(1/60)).*exp(((n.*pi.*(1/60)).^2).*t.*-4),n,1:10);
U = sum(utemp);
U = subs(U,t,0:5);
U = subs(U,x,1);
figure(1)
plot(0:5,U)

picture:

syms x n t
y1 = (x.*(120-x).*sin((n.*pi.*x)./60));
I1 = int(y1,x,0,60);
Cn = ((1/30).*I1);
utemp =
subs(Cn.*sin(n.*pi.*x.*(1/60)).*exp(((n.*pi.*(1/60)).^2).*t.*-4),n,1:1000);
U = sum(utemp);
U = subs(U,t,0:5);
U = subs(U,x,20);
figure(1)
plot(0:5,U)

picture:

syms x n t
y1 = (x.*(120-x).*sin((n.*pi.*x)./60));
I1 = int(y1,x,0,60);
Cn = ((1/30).*I1);
utemp =
subs(Cn.*sin(n.*pi.*x.*(1/60)).*exp(((n.*pi.*(1/60)).^2).*t.*-4),n,1:10);
U = sum(utemp);
U = subs(U,t,0:5);
U = subs(U,x,1);
figure(1)
plot(0:5,U)

picture:

syms x n t
y1 = (x.*(120-x).*sin((n.*pi.*x)./60));
I1 = int(y1,x,0,60);
Cn = ((1/30).*I1);
utemp =
subs(Cn.*sin(n.*pi.*x.*(1/60)).*exp(((n.*pi.*(1/60)).^2).*t.*-4),n,1:10);
U = sum(utemp);
U = subs(U,t,0:5);
U = subs(U,x,1);
figure(1)
plot(0:5,U)
figure(1)
plot(0:5,U)

picture:

syms x n t
y1 = (x.*(120-x).*sin((n.*pi.*x)./60));
I1 = int(y1,x,0,60);
Cn = ((1/30).*I1);
utemp =
subs(Cn.*sin(n.*pi.*x.*(1/60)).*exp(((n.*pi.*(1/60)).^2).*t.*-4),n,1:10);
U = sum(utemp);
U = subs(U,t,1);
U = subs(U,x,0:60);
figure(1)
plot(0:60,U)

picture:

syms x n t
y1 = (x.*(120-x).*sin((n.*pi.*x)./60));
I1 = int(y1,x,0,60);
Cn = ((1/30).*I1);
utemp =
subs(Cn.*sin(n.*pi.*x.*(1/60)).*exp(((n.*pi.*(1/60)).^2).*t.*-4),n,1:10);
U = sum(utemp);
U = subs(U,t,2.5);
U = subs(U,x,0:60);
figure(1)
plot(0:60,U)

picture:

syms x n t
y1 = (x.*(120-x).*sin((n.*pi.*x)./60));
I1 = int(y1,x,0,60);
Cn = ((1/30).*I1);
utemp =
subs(Cn.*sin(n.*pi.*x.*(1/60)).*exp(((n.*pi.*(1/60)).^2).*t.*-4),n,1:10);
U = sum(utemp);
U = subs(U,t,4);
U = subs(U,x,0:60);
figure(1)
plot(0:60,U)

picture: