function P3_01 clear, clc, format short g, format compact xyData=[-187.68 1.268E-06 -183.15 7.268E-06 -173.15 0.0001883 -163.15 0.0025884 -153.15 0.0221106 -143.15 0.1315085 -133.15 0.5900482 -123.15 2.117681 -113.15 6.352669 -103.15 16.50044 -93.15 37.87601 -83.15 78.7521 -73.15 150.754 -63.15 269.2572 -53.15 453.7621 -42.08 757.5202 -33.15 1110.03 -23.15 1635.044 -13.15 2332.562 -3.15 3225.086 6.85 4365.116 16.85 5767.654 26.85 7485.2 36.85 9525.254 46.85 1.2E+04 56.85 1.485E+04 66.85 1.823E+04 76.85 2.213E+04 86.85 2.663E+04]; X=xyData(:,1); m=size(X,1); %Determine the number of data points Y=xyData(:,2); prob_title = ([' Antoine Equation Parameters, Nonlinear Regression']); dep_var_name=['Vapor Pressure (mmHg) ']; ind_var_name=['Temperature (C)']; parm=[6 -1000 200]; npar=size(parm,2); % Determine the number of the parameters options=optimset('MaxFunEvals',1000); % Change the default value for MaxFunEvals Beta=fminsearch(@AntFun,parm,options,X,Y); % Find optimal parameters using fminsearch [f,Ycalc]=AntFun(Beta,X,Y); % Compute Y (calculated) at the optimum disp([' Results,' prob_title ]); Res=[]; for i=1:npar Res=[Res; i Beta(i)]; end disp(' Parameter No. Value '); disp(Res); s2=sum((Y-Ycalc)'*(Y-Ycalc))/(m-npar); %variance disp([' Variance ', num2str(s2)]); ymean=mean(Y); R2=(Ycalc-ymean)'*(Ycalc-ymean)/((Y-ymean)'*(Y-ymean));%linear correlation coefficient disp([' Correlation Coefficient ', num2str(R2)]) plot(Y,Y-Ycalc,'*') % Residual plot title(['Residual Plot, ' prob_title ]) xlabel([dep_var_name '(Measured)']) ylabel('Residual') pause plot(X,Ycalc,'r-',X,Y,'b+' ) %Plot of experimental and calculated data title(['Calculated/Experimental Data ' prob_title]) xlabel([ind_var_name]) ylabel([dep_var_name]) function [f,Ycalc]=AntFun(parm,X,Y) a=parm(1); b=parm(2); c=parm(3); for i=1:size(X,1); Ycalc(i,1)=10^(a+b/(X(i)+c)); end resid(:,1)=Y-Ycalc; f=resid'*resid;