clc;
clear;
x = 1: 16;
y = [4, 6.4, 8, 8.8, 9.22, 9.5, 9.7, 9.86, 10, 10.2, 10.32, 10.42, ...
10., 10.55, 10.58, 10.6];
y1 = @(b, t) b(1) * exp(-t/b(2)) +b(3)* exp(-t/b(4)) + b(5);
b0 = [-1, 1, -1, 1, 1];
opt = optimoptions('lsqcurvefit', 'StepTolerance', 1e-16, ...
'MaxFunctionEvaluations', 1e4, ...
'FunctionTolerance', 1e-16);
beta = lsqcurvefit(y1, b0, x, y, [], [], opt);
xp = 1: 0.1: 16;
yp = y1(beta, xp);
plot(x, y, 'ko');
hold on;
plot(xp, yp, 'r');
legend({'data', 'fit'}, 'location', 'northwest');
grid on; grid minor;
xlabel('x'); ylabel('y');
set(gca, 'fontsize', 15);