How to plot values of a matrix?
Afficher commentaires plus anciens
I have attached my code below. I want to plot the values of 'steadystate' during the while loop as 4 different lines on the same plot. How do I do that?
while abs(steadystate-concoutGuess)>0.0000001
bigmatrix=alt_bigmatrix;
concoutGuess=steadystate;
concout=steadystate;
fA= ((flowinA*concinA-flowout*concout(1))/Vol) - k1*concout(1)*concout(2);
fB= ((flowinB*concinB-flowout*concout(2))/Vol) - k1*concout(1)*concout(2) - k2*concout(2)*concout(3);
fC= ((-flowout*concout(3))/Vol) + k1*concout(1)*concout(2) - k2*concout(2)*concout(3);
fD= ((-flowout*concout(4))/Vol) + k1*concout(2)*concout(3);
molflow = [ fA; fB; fC; fD ];
bigmatrix= subs(bigmatrix);
differential=inv(bigmatrix);
differential=vpa(differential,8);
molflow=vpa(molflow,8);
steadystate = concoutGuess - (differential*molflow);
steadystate = vpa(steadystate,8)
end
Réponses (1)
Image Analyst
le 21 Avr 2018
0 votes
Have you tried the plot() function?
What did you intialize steadystate and concoutGuess with, so we can try your code?
4 commentaires
Remston Martis
le 21 Avr 2018
Modifié(e) : Remston Martis
le 21 Avr 2018
Image Analyst
le 21 Avr 2018
This does not work:
concoutGuess = [0.1;0.1;0.1;0.1] while abs(steadystate-concoutGuess)>0.0000001 bigmatrix=alt_bigmatrix; concoutGuess=steadystate; concout=steadystate; fA= ((flowinA*concinA-flowout*concout(1))/Vol) - k1*concout(1)*concout(2); fB= ((flowinB*concinB-flowout*concout(2))/Vol) - k1*concout(1)*concout(2) - k2*concout(2)*concout(3); fC= ((-flowout*concout(3))/Vol) + k1*concout(1)*concout(2) - k2*concout(2)*concout(3); fD= ((-flowout*concout(4))/Vol) + k1*concout(2)*concout(3); molflow = [ fA; fB; fC; fD ]; bigmatrix= subs(bigmatrix); differential=inv(bigmatrix); differential=vpa(differential,8); molflow=vpa(molflow,8); steadystate = concoutGuess - (differential*molflow); steadystate = vpa(steadystate,8) end
because you didn't give the intial values for steadystate. Again, what did you initialize steadystate to?
Remston Martis
le 21 Avr 2018
Modifié(e) : Remston Martis
le 21 Avr 2018
Image Analyst
le 22 Avr 2018
Sorry, I don't have the Symbolic Math toolbox. I've added it to the Products list on the upper right so others will know.
Catégories
En savoir plus sur Chemical Process Design dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!