Fit an equation with an integral

1 次查看(过去 30 天)
thatguy14
thatguy14 2015-11-2
评论: thatguy14 2015-11-2
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.

回答(1 个)

Star Strider
Star Strider 2015-11-2
How did you define your ‘Cpt’ function?
Where did you define it (anonymous function or its own function file)?
  1 个评论
thatguy14
thatguy14 2015-11-2
Yea I just realized I had forgot to define it as a anonymous function. That would fix it but I don't quite think that it will work how I want it to anyways... I may have to rethink this.

请先登录,再进行评论。

类别

Help CenterFile 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!

Translated by