% OBJECTIVE FUNCTION
f = @(x,b) b(1)*(1-exp(-b(2)*x))

% PROBLEM SETUP

dim = 2 % dimension of the minimization problem
nb = 6 % number of points

% NIST certified values
target = zeros(dim,1)
target(1) = 2.1380940889E+02
target(2) = 5.4723748542E-01

% start 1
ig1 = [1;1]
% start 2
ig2 = [100;0.75]

% points to fit
x = zeros(nb,1)
y = zeros(nb,1)
y(1) = 109; x(1) = 1;
y(2) = 149; x(2) = 2;
y(3) = 149; x(3) = 3;
y(4) = 191; x(4) = 5;
y(5) = 213; x(5) = 7;
y(6) = 224; x(6) = 10;

% GRAPHIC REPRESENTATION
scatter(x,y)

% OPTIMIZATION 
rng(0)	% for tractability 
[b,info] = lsqcurvefit(f,ig1,x,y)	% running minimization 

% ANIMATION
% Uncomment the following code to generate animation % 
% rng(0)
% [~,info] = lsqcurvefit(f,ig1,x,y)
% info.plot = 'fit'
% info.animate = true	% plot animation 
% optimview('lsqcurvefit',info) 