Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

%Input your own values

%File name: solutionscript


clear
clc
format short g
format compact
fprintf(2,'**********************************************************\n')
fprintf(2,'*

Steady-state Material Balances on Separation Train

*\n')

fprintf(2,'**********************************************************\n')
fprintf('<a href="">NOTE: Input the values of streams in matrix form enclosed in []
\n</a>\n')
prompt1 = '\n Input the output concentration starting from xylene,\n styrene
toluene then finally benzene of \n D1 :';
D1=input(prompt1);
prompt2 = '\n Input the output concentration starting from xylene,\n styrene
toluene then finally benzene of \n B1 :';
B1=input(prompt2);
prompt3 = '\n Input the output concentration starting from xylene,\n styrene
toluene then finally benzene of \n D2 :';
D2=input(prompt3);
prompt4 = '\n Input the output concentration starting from xylene,\n styrene
toluene then finally benzene of \n B2 :';
B2=input(prompt4);
A = [D1;B1;D2;B2]
prompt = '\n What is the feed concentration starting from xylene, \n styrene
toluene then finally benzene? ';
b = input(prompt)
Ainv = inv(A)
% part (a)
disp('The solution for D1 B1 D2 B2 is: ');

A = Ainv*b
pause

%part (b)

for i = 1:4
b_1 = b;
b_1(i) = b(i)*0.99;
disp('The solution for D1 B1 D2 B2 with one % reduction is: ');
x_1 = Ainv*b_1
b_2 = b;
b_2(i) = b(i)*0.98;
disp('The solution for D1 B1 D2 B2 with two % reduction is: ');
x_2 = Ainv*b_2
pause
end

%part (c)

D1 = A(1);
B1 = A(2);
disp('Calculations for D');
D = D1+B1
x_Dx = (0.07*D1+0.18*B1)/D
x_Ds = (0.04*D1+0.24*B1)/D
x_Dt = (0.54*D1+0.42*B1)/D
x_Db = (0.35*D1+0.16*B1)/D

D2 = A(3);
B2 = A(4);

disp('Calculations for B');


B = D2+B2
x_Bx = (0.15*D2+0.24*B2)/B
x_Bs = (0.1*D2+0.65*B2)/B
x_Bt = (0.54*D2+0.10*B2)/B
x_Bb = (0.21*D2+0.01*B2)/B

%To solve problem given


%File name: solutionscriptproblem
clear
clc
format short g
format compact
A = [0.07 0.18 0.15 0.24; 0.04 0.24 0.1 0.65
0.54 0.42 0.54 0.1; 0.35 0.16 0.21 0.01]
b = [0.15*70; 0.25*70; 0.4*70; 0.2*70]
Ainv = inv(A)
% part (a)
disp('The solution for D1 B1 D2 B2 is: ');
x = Ainv*b
pause

%part (b)

for i = 1:4
b_1 = b;
b_1(i) = b(i)*0.99;
disp('The solution for D1 B1 D2 B2 with one % reduction is: ');
x_1 = Ainv*b_1
b_2 = b;
b_2(i) = b(i)*0.98;
disp('The solution for D1 B1 D2 B2 with two % reduction is: ');
x_2 = Ainv*b_2
pause
end

%part (c)

D1 = x(1);
B1 = x(2);
disp('Calculations for D');
D = D1+B1
x_Dx = (0.07*D1+0.18*B1)/D
x_Ds = (0.04*D1+0.24*B1)/D
x_Dt = (0.54*D1+0.42*B1)/D
x_Db = (0.35*D1+0.16*B1)/D

D2 = x(3);
B2 = x(4);
disp('Calculations for B');
B = D2+B2
x_Bx = (0.15*D2+0.24*B2)/B
x_Bs = (0.1*D2+0.65*B2)/B
x_Bt = (0.54*D2+0.10*B2)/B
x_Bb = (0.21*D2+0.01*B2)/B

You might also like