Solve Compartmental Model with lsqcurvefitting

1 view (last 30 days)
Inge
Inge on 7 Oct 2013
Answered: Matt J on 7 Oct 2013
Hi,
My question is about the following convolution:
C(t) = Ca(t) x K1*exp(-k2*t)
where x is the convolution. I have the x- and y-values of the signals C(t) and Ca(t). With a least squares estimation, I want to estimate the parameters K1 and k2.
I started this with the function lsqcurvefitting, for which I first set up the following function, like the example in the help file
function F = myfun(x,xdata)
F = (x(1)*exp(x(2)*xdata));
But, the problem is that I have two sets of xdata and two sets of ydata (from C(t) and Ca(t)). Is this problem even possible to solve with the lsqcurvefitting? because if I want to solve this with the following code, it does not like the function at all (and that is because I totally skipped the convolution with Ca(t), but I don't know how to implement this).
K0 = [0.02; 0]; % Starting guess
[K,resnorm] = lsqcurvefit(@myfun,K0,xdata,ydata)
Btw, the xdata and ydata mentioned in this script is from the C(t) dataset.
Hope this problem is clear to you. Thanks in advance :)
  2 Comments
Inge
Inge on 7 Oct 2013
No, but the xdata for both C(t) and Ca(t)is spaced in the same, non-uniformly manner. This is the xdata:
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 110 120 130 140 150 160 170 180 190 200 250 300 350 400 450
500 550 600 695 790

Sign in to comment.

Answers (1)

Matt J
Matt J on 7 Oct 2013
For a fixed k2, you should be able to do a numerical convolution using TRAPZ within your F(x,xdata) function.
Since your K1 function only affects the objective function linearly, you might also consider using
instead of LSQCURVEFIT.

Products

Community Treasure Hunt

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

Start Hunting!