Search code examples
matlabmodelingmathematical-optimizationcurve-fittingcurve

Matlab :Model fitting and optimization error


I have a defined values of input (time samples) output (concentration), I would like to fit a model in order to estimate the Parameter values of rate constants(here in this case rate constants were defined as K1 K2 K3)

I have used lsqcurvefit for optimization but i am incurring errors in my usage of lsqcurvefit solver

First the values of x variable(t) and y variable(c_tot)

c_tot =[0,0,0,396.979609003375,503.769614648079,285.408414510699,137.309948090421,...
        63.0089145454838,28.2076980338446,12.4169874862731,5.39698687726493,...
        2.32247111168307,0.971427824475975,0.396298705702665,0.154518313562792,...
        0.0563350826881436,0.0175309433420762,
         0.00589400762862266,0.00199918527022414];%Loading Sampled Mat file values for fitting the Estimates of K in it



t=[0 0.25 0.5 0.75 1 1.5 2 3 4 9 13 18 23 28 33 38 43 48 53];%time samples

now the model which needs to be fitted

%-----------Model to be fitted-------------------------------------
k1_r=0.014;%reference tissue rate constant

a1=17501;a2=28500;a3=65000;%Values of a1 a2 a3 of Arterial input function

b1=0.9;b2=0.2;b3=0.5;%Values of b1 b2 b3 of Arterial Input Function 

td=0.3% Indicates delay time

tmax=0.8% maximum peak time concentration

A = ((K(1)*K(2))/(k1_r*(K(2)+K(3))));
B = ((K(1)*K(3))/(k1_r*(K(2)+K(3))));

model=@(K,t)conv((a1 * exp(-b1 * (t - tmax))+...
               a2 * exp(-b2 * (t - tmax))) +...
               a3 * exp(-b3 * (t - tmax)),...
               (A*exp(-(K(2)+K(3))*t+B)),'same');

Now i have used initial estimates of the parameters(k1 k2 k3) which i would like to fit and called the solver

%----------------Assignment------------------------------------------------
K=[0.1 0.08 0.4];%  Initial estimates of K1 K2 K3

%----------------Least-square curvefitting---------------------------------

K_est=lsqcurvefit(model,K,t,c_tot);

plot(K_est,'o');


xlabel('Time(mins)');
ylabel('Concentration(Bq/ml)');

Following is the error that i am incurring

    Undefined function 'tomlablic' for input arguments of type 'double'.

Error in tomlabVersion (line 45)
[x1,x2,x3,x4,x5,x6,tomV,OS]=tomlablic(1);

Error in GetSolver (line 72)
[TomV,os,TV] = tomlabVersion;

Error in lsqnonlin (line 415)
   Solver = GetSolver(checkType([],Prob.probType),...

Error in lsqcurvefit (line 298)
[x, f_k, r_k, ExitFlag, Output, Lambda, J_k, Result] =...

I am not experienced enough to know what I could do in order to perform model fitting.

Does any other solver will help me in this or is there any Global optimization tool box with which i can fit in initialized values

Any tips are welcome...


Solution

  • You are missing some TOMLAB files (looks very much like a missing license file).

    Please make sure you have a complete installation of TOMLAB (which is sold by a company different from Mathworks) and try again.

    As an alternative to TOMLAB, you can try Matlab's Global Optimization toolbox.