
% Define the data sets that you are trying to fit the
% function to
X=10:.5:300;
Y =.5+exp(-1.0*(200./X)).*((200./X).^5+5*(200./X).^4+20*(200./X).^3+60*(200./X).^2+120*(200./X)+120)+1.5.*rand(size(X));
 
% Initialize the coefficients of the function
X0=[.5 200]';
 
% Set an options file for LSQNONLIN to use the
% medium-scale algorithm
options = optimset('Largescale','off');
 
% Calculate the new coefficients using LSQNONLIN
x=lsqnonlin(@fit_simpa,X0,[],[],options,X,Y);
 
% Plot the original and experimental data
Z_new=x(2)./X;
Y_new = x(1)+exp(-1.0.*Z_new).*(Z_new.^5+5.*Z_new.^4+20.*Z_new.^3+60.*Z_new.^2+120.*Z_new+120);
plot(X,Y,'+r',X,Y_new,'b')