How to store variables from fsolve in a for loop

I am trying to store the calculated values from fsolve for each iteration. My program gives me the right answer at the end of the for loop, but I want to show the other calculated values as the program goes through the loop.
clc
clear
x(1) = 0
x(2) = 530
x(3) = 530
i=0
for i=1:140
x(1)=x(1)+(i*(1/254.545));
x(2)=x(2)+i;
x(3)=x(3)+i;
cA(i)=x(1);
T(i)=x(2);
Tj(i)=x(3);
x0=[cA(i),T(i),Tj(i)];
options = optimoptions('fsolve','Display','iter');
fun=@project2NLA;
c=fsolve(fun,x0,options)
end
Function file
function F = project2NLA(x)
V=48;
Vj= 12;
f=40; %ft^3/h
fj=49.9; % ft^3/h
cao=.55; %lbmol/ft^3
cp = 0.75; %BTU/lbR
cpj = 1; %BTU/lbR
E=30000; %BTU/lbmol
R=1.987; %BTU/lbmolR
p=50; %lb/ft^3
pj=62.3; %lb/ft^3
U= 150 ; %BTU/hft^2R
A=250 ; %250 ft^2
hrxn=-30000; %BTU/lbmol
To=530;
p=50 ; %lb/ft^3
pj=62.3 ; %lb/ft^3
ca=x(1); %concentration for A
T=x(2); %temperature of reactor
Tj=x(3);%temperature of jacker
k=(7.08*10^10)*exp(-E/(R*T));
F(1)=((cao*f)/V)-((ca*f)/V)-(k*ca);
F(2)=((f*p*cp)*(To-T))-(V*hrxn*k*ca)-(U*A*(T-Tj));
F(3)=((fj*pj*cpj)*(To-Tj))+(U*A*(T-Tj));

Asked:

on 6 Apr 2016

Answered:

on 6 Apr 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!