%%Part B : matrix form solution using eigenvalues and
eigenvectors
%Question 6 - 7
clear all
close all
clc
%Heating/Cooling constants
k1 = 0.2; k2 = 0.1; k3 = 0.2; %Cooling constant for the main
room
k0 = 0.5; k4 =
0.1;
%Cooling constants for attic and basement
%Temperature and the heater
TE = +40;
TS = -40;
H = 20;
T0 = [20.0 ; 0.0 ; -20.0]'; %Initial temperature in each
room
%Question 6.a.
A = [-(k0+k1) k1 0; k1 -(k1+k2+k3) k3; 0 k3 -(k3+k4)];
fprintf('3X3 Matrix A= \n\n')
disp(vpa(A,4))
%Question 6.b.
f = [k0*TE; k2*TS+H; k4*TS];
fprintf('Matrix f= \n')
disp(f)
syms s
I=eye(3);
Ts=(inv(s*I-A))*(T0+f/s);
fprintf('Value for Ts=\n')
disp(Ts)
Tinf=vpa(limit(s*Ts,0),4);
fprintf('Value for Tinf=\n')
disp(Tinf)
Tt=vpa(ilaplace(Ts),4);
fprintf('Value for Tt=\n')
disp(Tt)
Tt=vpa(simplify(rewrite(Tt,'exp')),4);
fprintf('Value for Tt after simplyfication=\n')
disp(Tt)
fprintf('Value for T final=\n')
disp(Tinf(:,1))
&Part Bmatrix form solution using eigenvalues and eigenvectors %Question 6-7 clear all close all clc Heating/Cooling constants k1-0.2 ; k2-0.1 ; k3-0.2 ; %cooling constant for the main room %cooling constants for attic and basement %Temperature and the heater TE-+40; TS--40 H20; TO- [ 20.0 ; 0.0 ; -20.01'; %Initial temperature in each room %Question 6.a. fprintf3X3 Matrix A-n') disp (vpa (A,4)) %Question 6.b. fprintf("Matrix f= disp(f) \n') syms s I-eye(3) Ts-(inv(s*I-A)) (TO+f/s) fprint f ("value for Ts=\n') disp (Ts) Tinf-vpa (limit (s Ts, 0),4); fprintf( 'Value for Tinf-In') disp (Tinf) Tt-vpa (ilaplace (Ts), 4) fprintf( 'Value for Tt n disp (Tt) Tt-vpa (simplify(rewrite(Tt, "exp,4); fprintf('value for Tt after simplyfication=\n') disp (Tt)
fprintf( 'Value for T final-\n') disp(Tinf(:,1)) 3X3 Matrix A- [-0.7, 0.2,01 [ 0.2,-0.5, 0.2) I0 0.2,-0.31 Matrix f- 20 16 Value for TS (4 (10*s 3)* (16/s + 20))/(200*s 3300 s2+ 126*s + 13) - (8 (4/s - 20))/(200*s 3300*s 2 126*s 13) (2* (20/s + 20)*(100*s 2 80*s 11))/(200 s3 300 s 2 + 126*s 13) (64 (10s3))/(s (200 s 3 300*s 2 126*s 13)32 (s (200 s 3 300 s 2 126*s 13)) (40 (100*s 2+80*s 11))/ (s (200 s 3+ 300*s 2 126*s 13)) s - 20))/(200*s 3 + 300*s 2 126 s 13) - (8*(4/s +20))/ (200 s3 +300 *s2 126s 13) (2* (20/s 20)*(100*s 2 80*s 11))/ (200*s 3 300*s2 126*s +13)1 ( (4*(10*s 3) *(20/s 20))/(200*s 3 300*s 2 + 126*s 13)- (4 (10*s7)*(4/s- 20))/(200*s 3300*s 2 126*s 13) + (2*(10*s + 3) (10 s 7) *(16/s 20))/(200*s 3 +300*s2 126*s + 13), (80 (10*s + 3))/(s (200*s 3 300*s 2+ 126*s+ 13)) - (16*(10*s + 7))/(s*(200*s 3 300s2126*s 13)) (32 (10 s 3)(10s + 7))/s*(200*s 3300*2 126*s + 13)), (4 (10*s 3) *(20/s - 20)) (200*s 3 300 s2 126*s 13) - (4*(10*s 7) *(4/s 20))/(200 s3 +300 *s 2 + 126*s13)+ (2* (10*s 3) (10 s7) (16/s - 20))/ (200*s 3 300 s2126*s 13) 1 (4* (10*s 3)(16 (8 (20/s +20))/(200 *s 3+300s2+ 126*s + 13) + (4* (10*s 7)*(16/s 20)/(200*s 3 300 s2 126*s 13) - (2* (4/ s - 20)* (100*s 2+120*s 31))/(200*s 3 +300 *s2 126 *s13), 160/(s* (200 s 3 300 s 2 126 s 13)) (64(10 s + 7))/s*(200*s 3+300*s2 126*s 13)) - (8 (100 s 2 120*s + 31)/(s (200 s 3 + 300*s 2 126s13)) (200*s 3 300s 2+126*s 13) (4 (10*s t 7) *(16/s - 20))/(200*s 3 +300 s 2+126*s 13) - (2* (4/s + 20) *(100 s 2 120*s 31))/ (200*s 3 300s2126*s 13)1 (8 (20/s - 20))/ Value for Tinf [ 46.15, 46.15, 46.15] [61.54, 61.54, 61.54 [ 27.69, 27.69, 27.69j Value for Tt- 46.15 -6.154 texp(-0.5*t) *(cosh (0.3464*t) + 1.443*sinh (0.3464*t)) - 20.0*exp(-0.5*t), 46.15 - 19.49*exp (-0.5*t) *(cosh (0.3464*t) +0.4558 sinh (0.3464*t)) - 26.67 exp(-0.5*t), 46.15 -
32.82 exp (-0.5*t) (cosh (0.3464*t) 0.2706*sinh (0.3464*t)) - 33.33*exp (-0.5*t) ] [ 61.54 - 21.54 *exp(-0.5*t)*(cosh(0.3464*t) 0.9073 *sinh(0. 3464*t)) -20·0+exp(-0 . 5 *t ) , 61 . 54-34. 8 7 *exp(-0 . 5 *t ) * (cosh( 0 . 3464 *t ) + 1.223 sinh 0.3464*t)) - 26.67 exp(-0.5*t), 61.54 - 48.21 *exp (-0.5*t)*(cosh (0.3464*t) + 1.364*sinh(0.3464*t)) 33.33 exp(-0.5*t)J [ 20.0 exp(-0.5*t- 27.69*exp(-0.5*t)* (cosh (0. 3464*t) + 1.026 sinh(0.3464*t)) 27.69, 26.67*exp(-0.5*t) - 54.36 *exp (-0.5*t) *(cosh (0.3464*t) 0.9477*sinh (0.3464*t))+ 27.69, 33.33*exp (-0.5*t) - 81.03 exp(-0.5*t)* (cosh(0.3464*t) + 0.9208*sinh(0.3464*t)) 27.691 Value for Tt after simplyfication- [ 1.364 *exp (-0.8464*t) - 7.518*exp(-0.1536*t) - 20.0 exp(-0.5*t) +46.15, 46.15 - 14.18*exp(-0.1536*t)-5.302*exp(-0.8464*t) - 26.67 *exp(-0.5*t), 46.15 - 20.85 *exp(-0.1536*t) - II.97*exp (-0.8464*t) - 33.33*exp(-0.5*t)) [ 61.54 - 20.54*exp(-0.1536*t) - 0.9987*exp(-0.8464*t) 20.0*exp(-0.5*t), 3.882 *exp (-0.8464*t) - 38.75*exp(-0.1536*t) - 26.67 *exp(-0.5*t) + 61.54, 8. 762*exp(-0.8464*t) - 56.97*exp(-0.1536*t)-33.33*exp(-0.5*t) 61.54] [ 20.0*exp (-0.5*t) - 28.06*exp (-0.1536*t) + 0.3655 exp (-0. 8464*t) +27.69, 26.67 exp(-0.5*t -52.94*exp(-0.1536*t) - 1.421 *exp(-0.8464*t) 27.69, 33.33*exp (-0.5*t) - 77.82*exp(-0.1536*t - 3.207*exp-0.8464*t) + 27.69] value for T final= 46.153846153873018920421600341797 61.538461538497358560562133789062 27.692307692312169820070266723633 Published with MATLAB R2018a