How to keep the values from every loop that solves a system in a single matrix?
Show older comments
clear all for drog=1:60; syms cg1 cg2 cp1 cp2 x1 eqn1=cg1+cp1==0.05*drog; eqn2=cg2+cp2==0.15*drog; eqn3=cg1==(132.24/(0.082*298))*x1; eqn4=cg2==(132.24/(0.082*298))*(1-x1); eqn5=x1==(cp1/132.24)/((cp1/132.24)+(cp2/132.24)); s=solve(eqn1, eqn2, eqn3, eqn4, eqn5, cg1, cg2, cp1, cp2, x1) a=s.cp1; end
In every loop i want to keep the solution cp1 in a matrix, so that at the end of all the loops i will have the results in a single matrix. How can i do that? can you please help me???
Accepted Answer
More Answers (1)
Andrei Bobrov
on 4 Jun 2017
syms cg1 cg2 cp1 cp2 x1 drog
eqn1=cg1+cp1==0.05*drog;
eqn2=cg2+cp2==0.15*drog;
eqn3=cg1==(132.24/(0.082*298))*x1;
eqn4=cg2==(132.24/(0.082*298))*(1-x1);
eqn5=x1==(cp1/132.24)/((cp1/132.24)+(cp2/132.24));
s=solve(eqn1, eqn2, eqn3, eqn4, eqn5, cg1, cg2, cp1, cp2, x1);
a=matlabFunction(s.cp1);
drog = (1:60)';
out = a(drog)
Categories
Find more on Loops and Conditional Statements 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!