MATLAB/solving Linear Systems Solve the following linear systems of equations fo
ID: 2963151 • Letter: M
Question
MATLAB/solving Linear Systems
Explanation / Answer
clear;
clc;
%for part a
% dcA/dt=-k1 cA+k2 cB (1)
% dcB/dt=k1 cA - (k2+k3) cB+ k4cC (2)
% dcC/dt=k3 cB- k4cC (3)
% k1=2, k2=1, k3=2 , k4=2
% [2 3 10]
% dcA/dt=-2 cA+ cB .... (1)
% dcB/dt=2 cA - (3) cB+ 2 cC (2)
% dcC/dt=2 cB- 2 cC (3)
disp('solution for part a');
A= [ -2 1 0
2 -3 2
0 2 -2];
b=[ 2
3
10];
if(det(A)==0)
disp('the determinant is singular');
end
x=rref([A b])
X=sprintf(' cC = t and cB = %0.2f t and cA = %0.2f t ',x(2,4),x(2,3),x(1,4),-x(1,3));
disp(X);
%for part b--------------------------
A=[3 1 -2
1 2 -1
1 0 1];
b= [1
0
-5];
format shortg;
x=A;
disp('solution for part b');
disp(x);
% for part c------------------------
clear A b x;
A= [ 4 2
1 -1
3 -4];
b= [3
-1
7];
x= A;
disp('solution for part c');
disp(x);
%for part d------------------------------
disp('solution for part d');
clear A b x
A=[1 2 3
4 3 2
5 5 5];
if(det(A)==0)
disp('the determinant is singular');
end
b= [1
2
3];
x=rref([A b])
X=sprintf('here x3 = t and x2 = %0.2f - %0.2ft and x1 = %0.2f + %0.2ft',x(2,4),x(2,3),x(1,4),-x(1,3));
disp(X);
%---------------------------output window-------------------------------------------------------------------------------
solution for part a
the determinant is singular
x =
1 0 -0.5 0
0 1 -1 0
0 0 0 1
cC = t and cB = 0.00 t and cA = -1.00 t
cC = t and cB = 0.00 t and cA = 0.50 t
solution for part b
-1.625
-0.875
-3.375
solution for part c
1.0883
-0.74088
solution for part d
the determinant is singular
x =
1 0 -1 0.2
0 1 2 0.4
0 0 0 0
here x3 = t and x2 = 0.40 - 2.00t and x1 = 0.20 + 1.00t
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.