How to plug values into a symbolic matrix?

12 views (last 30 days)
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

Accepted Answer

Remston Martis
Remston Martis on 19 Apr 2018
Have managed to figure out the solution.
For other interested in the answer to this
Code:
Bigmatrix=subs(bigmatrix)
  1 Comment
Sudip Karmacharya
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)?

Sign in to comment.

More Answers (0)

Categories

Find more on Chemistry in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!