I'm replicating a calculation done in Excel with Matlab. The spreadsheet used Solver to find the smallest difference between a given value and an estimated value from a known function. The function is y=a+b*exp(c*x) where parameters a, b and c are to be estimated, x is the age. The formula is applied for range of ages and the minimum is the square difference (y_given-y_estimated)^2.
I'm able to use the function fminunc for one age but struggle to have this to a range of ages. My program looks like this
param0 = [0,0.2,1.2];
function res = f_Makeham(param,y_given)
res = a0+b0.*exp(c0.*x);
This obviously generates an error.
How can I change the program to consider the minimum difference for a range of ages, and estimate a, b and c for those ages?