Fit an equation with an integral

1 view (last 30 days)
thatguy14
thatguy14 on 2 Nov 2015
Commented: thatguy14 on 2 Nov 2015
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.

Answers (1)

Star Strider
Star Strider on 2 Nov 2015
How did you define your ‘Cpt’ function?
Where did you define it (anonymous function or its own function file)?
  1 Comment
thatguy14
thatguy14 on 2 Nov 2015
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.

Sign in to comment.

Categories

Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!