How to plot values of a matrix?
Show older comments
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
Answers (1)
Image Analyst
on 21 Apr 2018
0 votes
Have you tried the plot() function?
What did you intialize steadystate and concoutGuess with, so we can try your code?
4 Comments
Remston Martis
on 21 Apr 2018
Edited: Remston Martis
on 21 Apr 2018
Image Analyst
on 21 Apr 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
on 21 Apr 2018
Edited: Remston Martis
on 21 Apr 2018
Image Analyst
on 22 Apr 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.
Categories
Find more on Chemical Process Design in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!