How to plug values into a symbolic matrix?
Show older comments
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
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!