MATLAB: Curve fitting with an if statement

curve fittingCurve Fitting Toolboxif statement

I am using the curve fitting app on matlab to fit the following function to my data set:
y(x) = (a0*(1-exp(-b0*(x-c0))))+(a1*(1-exp(-b1*(x-c1))))
However, I would like to alter the equation to be:
y(x) = ((a0*(1-exp(-b0*(x-c0))))*u0)+((a1*(1-exp(-b1*(x-c1))))*u1)
with the following command
u0 = if(x<c0,0,1)
u1= if(x<c1,0,1)
i.e. y would equal 0 until x passes c0 and y(x) would equal the first part of the equation between c0 and c1 and the full model from c1 onwards.
Please see page three on the attached pdf under VO2 kinetics for a similar example.
Any help would be greatly appreciated.

Best Answer

y = @(x) ((a0*(1-exp(-b0*(x-c0)))).*(x>=c0)) + ((a1*(1-exp(-b1*(x-c1)))).*(x>=c1))
Related Question