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.

 채택된 답변

Walter Roberson
Walter Roberson 2019년 5월 23일
편집: Walter Roberson 2019년 5월 23일

1 개 추천

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

댓글 수: 2

Julian Dale
Julian Dale 2019년 5월 23일
Hi Walter,
Thanks for your quick response. Would it be correct to say that .* means when.
Thanks
Julian
.* means element-by-element multiplication.
The result of a logical test is a logical array of true and false values. In many circumstances, the value false is automatically converted to 0, and the value true is automatically converted to 1. So if you multiply by a logical value, then if the logical value was false, that is multiplication by 0, and if the logical value was true, then that is multiplication by 1.
The situation you need to watch out for is the case where an unselected case generates infinity:
(1./x).*(x ~= 0) + -1 .* (x == 0)
looks like it should express:
x == 0 -> -1
x ~= 0 -> 1/x
However, when x is 0, then 1/x is inf, and you would be calculating (inf).*(0) but inf*0 is NaN, and NaN + anything is NaN.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2019년 5월 23일

댓글:

2019년 5월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by