Beruflich Dokumente
Kultur Dokumente
clc
clear all
g=trace(A);
difference=f-g
l=eye(3,3);
difference=det(k-l)
%part b)
fprintf('\nPart B\n')
%rank of A
fprintf('Rank of A\n')
rank=rank(A)
%Determinant of A
fprintf('Determinant of A\n')
fprintf('Determinant is defined for square matrices. Because A is not a square matrix\n')
fprintf('Evaluation determinant for A is not possible.\n')
%part c)
fprintf('\nPart C\n')
A=[1 1 1 0 0 0 0 0 0 0 0 0 0 0;
1.17 0 0 -1 0 0 0 0 0 0 0 0 0 0;
00001000000000;
0 0 1 0 1 -1 -1 -1 0 0 0 0 1 0;
0 0 0 0 0 1 1 1 1 -1 -1 0 0 0;
0 0 0 1 0 0 0 0 0 0 0 0 -1 0;
1 0 0 -1 0 0 0 0 0 1 0 0 0 1;
0 0 0 0 0 0 0 0 0 4.594 0 0 0 0.11;
0 0 0 0 0 0 0 0 1 0 0 0 0 0;
0 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 0 0 0 0 0 0 -0.0147;
0 0 1 0 0 0 0 0 0 0 0 -0.07 0 0;
0 0 0 0 0 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 -1 0 1];
d=[43.93 0 95.798 99.1 -8.4 24.2 189.14 146.55 10.56 2.9056 0 0 14.6188 -97.9];
c=d';
%try two method for solving the given linear equation
fprintf('\nMethod of x=inv(A)*c\n')
x1=inv(A)*c
%Optional part show that whether both methods give the same result or not,
%that part controls row by row
fprintf('*Optional part*\n\n')
tolerance = 0.00000001;
for i=[1:1:14]
if abs(x1(i,1)-x2(i,1)) < tolerance
fprintf('the two method give same result for row %i\n',i);
else
fprintf('the two method does not give same resultfor row %i\n',i);
end
end
%check whether it give the same results with p.111, Table E2.2
x1(8)=0;
fprintf('\nThe x matrix @Page 111 Table E2.2')
x=[20.7;2.9;20.3;24.2;95.8;2.4;14.6;0.0;10.6;28.0;8.0;290.6;0.0;164.7]
Output
Part A
A=
0.7400 0.9706 0.3664
0.2348 0.8669 0.3692
0.7350 0.0862 0.6850
B=
0.5979 0.2060 0.2057
0.7894 0.0867 0.3883
0.3677 0.7719 0.5518
C=
0.2290 0.1518 0.2941
0.6419 0.7819 0.2374
0.4845 0.1006 0.5309
eqn.2.48 (A+B)"=A"+B"
difference =
0
eqn.2.49 (A*B)"=(B")*(A")
difference =
0
eqn.2.60 sum(eig(A))=trace(A)
difference =
-4.4409e-016
eqn.2.62 A*inv(A)=inv(A)*A
difference =
0
difference =
2.2024e-048
eqn.2.63 (A*B)^-1=(B^-1)*(A^-1)
difference =
2.8376e-044
eqn.2.64 (A*B*C)^-1=(C^-1)*(B^-1)*(A^-1)
difference =
4.1613e-041
Part B
A=
3
2 -4
4 -8
Rank of A
rank =
2
Determinant of A
Determinant is defined for square matrices. Because A is not a square matrix
Evaluation determinant for A is not possible.
Part C
Method of x=inv(A)*c
x1 =
20.6854
2.9056
20.3390
24.2020
95.7980
2.4211
14.6188
-0.0010
10.5600
27.9567
8.0422
290.5565
0.0020
164.6998
Method of x=A|c
x2 =
20.6854
2.9056
20.3390
24.2020
95.7980
2.4211
14.6188
-0.0010
10.5600
27.9567
8.0422
290.5565
0.0020
164.6998
*Optional part*
the two method give same result for row 1
the two method give same result for row 2
the two method give same result for row 3
28.0000
8.0000
290.6000
0
164.7000
The x matrix that we found
x1 =
20.6854
2.9056
20.3390
24.2020
95.7980
2.4211
14.6188
0
10.5600
27.9567
8.0422
290.5565
0.0020
164.6998