Store whileloop vector values in a matrix
显示 更早的评论
I want to store output 'steadystate' (a column vector) as a matrix as steadystate(1), steadystate(2),steadystate(3), steadystate(4).
I have not posted my whole code. Initial gues councoutGuess=[0.1;0.1;0.1;0.1] initial steadystate values = [ 0.1504734, -0.049281077, 0.14977213, 0.34987724]
while abs(steadystate-concoutGuess)>0.0000001 %Convergence error criteria for the Newton Rhapson loop
bigmatrix=alt_bigmatrix; %Using the stored symbolic matrix for the loop calculations
concoutGuess=steadystate; %Updating values
concout=steadystate;
fA= ((flowinA*concinA-flowout*concout(1))/Vol) - k1*concout(1)*concout(2); %Recalcualting values similar to previous calculations
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); %Substituting updated values and calculating in symbolic form
differential=inv(bigmatrix);
differential=vpa(differential,8);%Evaluating symbolic and rounding to specified significant figures
molflow=vpa(molflow,8);
steadystate = concoutGuess - (differential*molflow); %Newton Rhapson formula for steady state
i=i+1;
steadystate = vpa(steadystate,8);
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!