function C=kinetics(theta,t)
[T,Cv]=ode45(@DifEq,t,c0);
dcdt(1)=-theta(1).*c(1)-theta(2).*c(1);
dcdt(2)= theta(1).*c(1)+theta(4).*c(3)-theta(3).*c(2)-theta(5).*c(2);
dcdt(3)= theta(2).*c(1)+theta(3).*c(2)-theta(4).*c(3)+theta(6).*c(4);
dcdt(4)= theta(5).*c(2)-theta(6).*c(4);
c=[0.902 0.06997 0.02463 0.00218
0.8072 0.1353 0.0482 0.008192
0.6757 0.2123 0.0864 0.0289
0.5569 0.2789 0.1063 0.06233
0.4297 0.3292 0.1476 0.09756
0.3774 0.3457 0.1485 0.1255
0.2149 0.3486 0.1821 0.2526
0.141 0.3254 0.194 0.3401
0.04921 0.2445 0.1742 0.5277
0.0178 0.1728 0.1732 0.6323
0.006431 0.1091 0.1137 0.7702
0.002595 0.08301 0.08224 0.835];
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c,zeros(size(theta0)));
Local minimum possible.
lsqcurvefit stopped because the final change in the sum of squares relative to
its initial value is less than the value of the function tolerance.
fprintf(1,'\tRate Constants:\n')
fprintf(1, '\t\tTheta(%2d) = %23.15E\n', k1, theta(k1))
end
Theta( 1) = 7.648784502758464E-01
Theta( 2) = 2.348642320704391E-01
Theta( 3) = 2.089879571711175E-01
Theta( 4) = 4.920779719013652E-01
Theta( 5) = 6.221107591627785E-01
Theta( 6) = 1.175188421416447E-13
Theta( 7) = 9.028750693139709E-01
Theta( 8) = 7.145169346891880E-02
Theta( 9) = 2.840857166532932E-02
Theta(10) = 4.784361317284549E-12
tv = linspace(min(t), max(t));
Cfit = kinetics(theta, tv);
hd(k1).MarkerFaceColor = CV(k1,:);
hlp(k1).Color = CV(k1,:);
legend(hlp, compose('C_%d',1:size(c,2)), 'Location','best')