MATLAB: Set sum of coefficients to equal 1 in biexponential fit

constraintscurve fittingMATLAB

I'm trying to fit some data to a biexponential function ('exp2') and I want to constrain the a and c coeffients to sum to 1. Is there a way to do this?

Best Answer

You are using the exp2 model form
ft = fittype('exp2')
ft =
General model Exp2:
ft(a,b,c,d,x) = a*exp(b*x) + c*exp(d*x)
except that you wish to have the addirional constraint that a+c == 1.
Trivial. Just build the constraint into the model.
ft = fittype('a*exp(b*x) + (1-a)*exp(d*x)','indep','x')
ft =
General model:
ft(a,b,d,x) = a*exp(b*x) + (1-a)*exp(d*x)