Consider the process flow diagram shown in Fig. 2.14. We can write this out as t
ID: 3882911 • Letter: C
Question
Consider the process flow diagram shown in Fig. 2.14. We can write this out as the system of equations m1 = m2 + m3 + m4 + m5 m_2 = m_9 + m_10 + m_11 m_5 = m_8 + m_7+m_6 m_12 = m_4 + m_7 + m_11 m_1 =100 m_5 = 5 ms 0.84 m_12 = m_4 + m_7 0.7 m_1 = m_2 + m_3 0.55 m_1 = m_9 + m_12 0.2 m_9 = m_10 0.85m_2 = m_9 + m_11 3.2 m_6 = m_7 + m_8 The first four equations are the mass balances: the next eight equations are the process specifications. (a) Write a MATLAB program that generates the matrix A and vector b required to solve the problem for this set of equations. (b) Write a MATLAB program that solves this system using naive Gauss elimination. What happens? How do you fix it?Explanation / Answer
From the given equations A 12x12 matrix is:
1 -1 -1 -1 -1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 -1 -1 -1 0
0 0 0 0 1 -1 -1 -1 0 0 0 0
0 0 0 -1 0 0 -1 0 0 0 -1 1
1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 -5 0 0 0 0
0 0 0 -1 0 0 -1 0 0 0 0 0.84
0.70 -1 -1 0 0 0 0 0 0 0 0 0
0.55 0 0 0 0 0 0 0 -1 0 0 -1
0 0 0 0 0 0 0 0 0.20 -1 0 0
0 0.85 0 0 0 0 0 0 -1 0 -1 0
0 0 0 0 0 3.20 -1 -1 0 0 0 0
The b 12x1 matrix is:
0
0
0
0
100
0
0
0
0
0
0
0
Code:
%% Solve linear system of eqution Ax=b using Naive Gaussian Elimination Method
clc; clear all; close all;
A = [1,-1,-1,-1,-1,0,0,0,0,0,0,0;...
0,1,0,0,0,0,0,0,-1,-1,-1,0;...
0,0,0,0,1,-1,-1,-1,0,0,0,0;...
0,0,0,-1,0,0,-1,0,0,0,-1,1;...
1,0,0,0,0,0,0,0,0,0,0,0;...
0,0,0,0,1,0,0,-5,0,0,0,0;...
0,0,0,-1,0,0,-1,0,0,0,0,0.84;...
0.7,-1,-1,0,0,0,0,0,0,0,0,0;...
0.55,0,0,0,0,0,0,0,-1,0,0,-1;...
0,0,0,0,0,0,0,0,0.2,-1,0,0;...
0,0.85,0,0,0,0,0,0,-1,0,-1,0;...
0,0,0,0,0,3.2,-1,-1,0,0,0,0];
b = [0;0;0;0;100;0;0;0;0;0;0;0];
disp('A matix:')
disp(A)
disp('b matix:')
disp(b)
[n,~] = size(A);
%Initialize solution X
X = zeros(n,1);
%%Forward Elimination (convertion Of A to Upeer triangle matrix)
for i = 1:n-1
while A(i,i)==0
temp =A;
A = [temp(1:(i-1),:);temp(i+1:n,:);temp(i,:)];
tempb = b;
b = [tempb(1:(i-1),:);tempb(i+1:n,:);tempb(i,:)];
end
m = A(i+1:n,i)/A(i,i);
A(i+1:n,:) = A(i+1:n,:)-m*A(i,:);
b(i+1:n,:) = b(i+1:n,:)-m*b(i,:);
end
%%Back Substitution
X(n,:) = b(n,:)/A(n,n);
for i = n-1:-1:1
X(i,:) = (b(i,:) - A(i,i+1:n)*X(i+1:n,:))/A(i,i);
end
disp('Solution:')
disp(X)
Solution:
100.0000
40.0000
30.0000
9.4565
20.5435
4.8913
11.5435
4.1087
30.0000
6.0000
4.0000
25.0000
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.