Fit an equation with an integral
1 次查看(过去 30 天)
显示 更早的评论
I have an equation that I am trying to find the best way to fit. In its original form it is:
A * convolution (func1,func2) from 0 to t or put correctly:
A* integral from 0 to t of (function 1(t')*exp(-A*(t-t')/B)dt')
Function 2 has two fit parameters I wish to recover. Function 1 is just a function of time and I have a curve for it.
I thought it might be easier to split the convolution as follows:
exp(-A(t-t')/B) = exp(-At/B)*exp(At'/B) and took out the first exponential since it is not a function of t'. I then tried to fit this, here is my code
kineticModel = @(ve,Ktrans,x) Ktrans.*exp(-Ktrans.*x./ve).*integral(@(x) Cpt(x).*exp(Ktrans.*x./ve),timePoints(1)./60,timePoints(end)./60);
[kineticFit, GOF] = fit((timePoints./60)',Ct',kineticModel);
This is giving me an error (subscript indicies must be real or positive integers or something similar. I found this is coming from the Cpt(x) term.
To be honest I am not sure this is correct since it was originally a convolution. the integral is actually a function on its own as a function of t (0 to t1, 0 to t2 etc). I am trying to avoid the convolution since it is the discrete version and requires scaling by the spacing (the spacing of my time points is not linear).
Any help would be appreciated. Let me know if anything needs clarification.
0 个评论
回答(1 个)
Star Strider
2015-11-2
How did you define your ‘Cpt’ function?
Where did you define it (anonymous function or its own function file)?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!