MATLAB: Trying to solve the parameters for an equation

finding parametersfminsearch

There is a dataset for the following mathematical model, please use MATLAB to find these parameters a1、a2、b1 and b2
x=0:0.1:2
y=[xdata1 xdata2… xdata21]
y=a1*exp(b1*x)+a2*exp(b2*x)
I think it has something to do with fminsearch, but I don't know where to start

Best Answer

fun = @(ab) sum((ab(1)*exp(ab(3)*x) + ab(2) * exp(ab(4)*x) - y).^2)
ab0 = randn(1,4);
AB = fminsearch(fun, ab0);
a1 = AB(1); a2 = AB(2); b1 = AB(3); b2 = AB(4);