How to plug values into a symbolic matrix?
12 views (last 30 days)
Show older comments
Remston Martis
on 18 Apr 2018
Commented: Sudip Karmacharya
on 2 Nov 2020
I have developed a code pasted below :
:
syms concoutA concoutB concoutC concoutD fA fB fC fD
syms flowinA flowinB flowinC flowinD Vol concinA concinB concinC concinD
syms flowout k1 k2
fA= ((flowinA*concinA-flowout*concoutA)/Vol) - k1*concoutA*concoutB
fB= ((flowinB*concinB-flowout*concoutB)/Vol) - k1*concoutA*concoutB - k2*concoutB*concoutC
fC= ((-flowout*concoutC)/Vol) + k1*concoutA*concoutB - k2*concoutB*concoutC
fD= ((-flowout*concoutD)/Vol) + k1*concoutB*concoutC
molflow = [ fA; fB; fC; fD ]
bigmatrix = jacobian(molflow,[concoutA,concoutB, concoutC, concoutD])
concinA = input('Enter the concentration of Chemical A flowing into the reactor [kmol/m^3] : ')
concinB = input('Enter the concentration of Chemical B flowing into the reactor [kmol/m^3] : ')
k1=input('Enter desired rate of reaction 1 A+B->C [m^3/kmol*sec] : ')
k2=input('Enter desired rate of reaction 2 B+C->D [m^3/kmol*sec] : ')
flowinA=input('Enter the flowrate of Chemical A into the reactor [m^3/sec] : ')
flowinB=input('Enter the flowrate of Chemical B into the reactor [m^3/sec] : ')
Vol=input('Enter desired volume of reactor vessel [m^3] : ')
concoutGuess= input('Enter initial guess for final concentrations of chemical species A, B, C, D respectively in the format "[A B C D]" kmol/m^3 : ')
concoutA=concoutGuess(1);
concoutB=concoutGuess(2);
concoutC=concoutGuess(3);
concoutD=concoutGuess(4);
flowout=flowinA+flowinB;
fA= ((flowinA*concinA-flowout*concoutA)/Vol) - k1*concoutA*concoutB
fB= ((flowinB*concinB-flowout*concoutB)/Vol) - k1*concoutA*concoutB - k2*concoutB*concoutC
fC= ((-flowout*concoutC)/Vol) + k1*concoutA*concoutB - k2*concoutB*concoutC
fD= ((-flowout*concoutD)/Vol) + k1*concoutB*concoutC
molflow = [ fA; fB; fC; fD ]
end
I want to plug in the values for the inputs into "bigmatrix" but am not able to do so. 'bigmatrix' still outputs with variables names instead of calculated integer values. Is it because I have used symbolic? How do I get around this?
Providing the code will be very helpful! Thank you
0 Comments
Accepted Answer
Remston Martis
on 19 Apr 2018
1 Comment
Sudip Karmacharya
on 2 Nov 2020
Hey I'm not really sure what you did.
Did you specify the values for each variable in bigmatrix, and then excecuted Bigmatrix=subs(bigmatrix)?
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!