Hi all,
The following code produces a graph which compares simulated experimental results against actual experimental data points:
function API2function C=kinetics(theta,t)c0=[0.752;1.278;0];[T,Cv]=ode45(@DifEq,t,c0);%
function dC=DifEq(t,c) dcdt=zeros(3,1); dcdt(1)=-theta(1).*c(1).^2+theta(2).*c(2)-theta(3).*c(1).*c(2); dcdt(2)=theta(1).*c(1).^1-theta(2).*c(2).^1-theta(3).*c(1).^1.*c(2); dcdt(3)=theta(3).*c(1).*c(2).^3; dC=dcdt; endC=Cv;endT = [0 1 2 5 10 15];t = T';%y values for a
a_ydata = [0.752 0.0596 0.0596 0.0596 0.0502 0.0424];A_Ydata = a_ydata';%y values for b
b_ydata = [1.278 0.378 0.101 0.101 0.085 0.072];B_Ydata = b_ydata';c_ydata = [0 0.692 0.692 0.692 0.702 0.71];C_Ydata = c_ydata';c = [A_Ydata B_Ydata C_Ydata];theta0=[0.5;0.5;0.5];[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);fprintf(1,'\tRate Constants:\n')for k1 = 1:length(theta) fprintf(1, '\t\tTheta(%d) = %8.5f\n', k1, theta(k1))endtv = linspace(min(t), max(t));Cfit = kinetics(theta, tv);figure(1)h = plot(t, c,'.');set(h,{'Marker'},{'s';'d';'^'},{'MarkerFaceColor'},{'r';'b';'k'},{'MarkerEdgeColor'},{'r';'b';'k'});hold onhlp = plot(tv, Cfit,'LineWidth',1.5);set(hlp,{'Color'},{'r';'b';'k'});hold offgridxlabel('Time (min)')ylabel('Concentration (M)')legend(hlp, 'Rifamycin Oxazine', 'Piperazine', 'Rifampicin', 'Location','N')end
I want to know what code should be added so that I can see the R^2 value for each curve to see how accurate the simulated curve is. Thanks
Best Answer