Matlab 4
Matlab 4
........................................................................................................................................................ 1
Conor Carson Matlab 4 ........................................................................................................................ 1
Problem 30 ........................................................................................................................................ 1
Problem 33 ........................................................................................................................................ 3
Problem 34 ........................................................................................................................................ 3
Additional Problem 1 ........................................................................................................................... 4
Additional Problem 2 ........................................................................................................................... 5
clc
clear all
% a)
A*B
B*A
% no they are not equal
% b)
(B*C)^-1
(B^-1)*(C^-1)
% no they are not equal
% c
(inv(A))'
inv(A')
% yes they are equal
% d
(A+B)'
A'+B'
% yes they are equal
A =
5 -3 7
1 0 -6
-4 8 9
B =
3 2 -1
1
6 8 -7
4 4 0
C =
-9 8 3
1 7 -5
3 3 6
ans =
25 14 16
-21 -22 -1
72 92 -52
ans =
21 -17 0
66 -74 -69
24 -12 4
ans =
ans =
ans =
ans =
ans =
2
8 7 0
-1 8 12
6 -13 9
ans =
8 7 0
-1 8 12
6 -13 9
Problem 33
A=[-2 5 7; 3 -6 2; 9 -3 8];
B=[-17.5; 40.6; 56.2];
linsolve(A,B)
% x=3.2 y=-4.6 z=1.7
ans =
3.2000
-4.6000
1.7000
Problem 34
A=[2 -4 5 -3.5 1.8 4;
-1.5 3 4 -1 -2 5;
5 1 -6 3 -2 2;
1.2 -2 3 4 -1 4;
4 1 -2 -3 -4 1.5;
3 1 -1 4 -2 -4];
B=[52.52; -21.1; -27.6; 9.16; -17.9; -16.2;]
linsolve(A,B)
% a=1.8 b=-6.2 c=2.6 d=-1.6 e=4.4 f=-0.6
B =
52.5200
-21.1000
-27.6000
9.1600
-17.9000
-16.2000
ans =
3
1.8000
-6.2000
2.6000
-1.6000
4.4000
-0.6000
Additional Problem 1
A=[100 -300;300 600];
B=[12; -6]
a=A(1,1)
b=A(1,2)
c=A(2,1)
d=A(2,2)
dA=(a*d)-(b*c)
I=iA*B
% I1=.06 I2=.02
B =
12
-6
a =
100
b =
-300
c =
300
d =
600
dA =
4
150000
iA =
0.0040 -0.0020
0.0020 0.0007
I =
0.0600
0.0200
Additional Problem 2
A=[cosd(23.6) sind(23.6);sind(111.2) cosd(111.2)];
B=[0; 93]
a=A(1,1)
b=A(1,2)
c=A(2,1)
d=A(2,2)
dA=(a*d)-(b*c)
T=iA*B
% T1=123.0512 T2=-120.9446
B =
0
93
a =
0.9164
b =
0.4003
c =
5
0.9323
d =
-0.3616
dA =
-0.7046
iA =
0.5132 1.3231
0.5682 -1.3005
T =
123.0512
-120.9446