I use lsqcurvefit to fit my function. My function is:
C_PET (t)=(k_1/(α_2+α_1 ) [(k_3+k_4-α_1 ) e^((-α_1 t) )+(α_2-k_3-k_4 ) e^((-α_2 t) ) ]* C_P (t))+vC_b (t)
I went to find the solution, meaning the best fit for my K parametres. The problem is that the solution that my code give is the initial point. this is the code (vb is constant , cp,ydata,t are a vector
k0 = 1*ones(1,4);
k0(4) = 0;
k0 = [0.8,0.1,0.5,0.07]
a1=[k0(2)+k0(3)+k0(4)+sqrt(((k0(2)+k0(3)+k0(4)).^2) -4*k0(2)*k0(4))]/2;
a2=[k0(2)+k0(3)+k0(4)-sqrt(((k0(2)+k0(3)+k0(4)).^2) -4*k0(2)*k0(4))]/2;
l1=(k0(1)/(a2+a1))*(k0(3)+k0(4)-a1) l2=(a2-k0(3)-k0(4))
l2=(a2-k0(3)-k0(4))
y=conv((l1*exp(-a1*t)+l2*exp(-a2*t)),cp);
y=(y(1:numel(t)));
CPET=@(k,t) y+(vb*cp);
[xfitted,errorfitted] = lsqcurvefit(CPET,k0,t,ydata)
%
So please can you hep me.