Matlab:模型拟合和优化误差

时间:2014-05-20 10:54:06

标签: matlab modeling mathematical-optimization curve-fitting curve

我有输入(时间样本)输出(浓度)的定义值,我想拟合一个模型来估计速率常数的参数值(在这种情况下,速率常数定义为K1 K2 K3)

我使用了lsqcurvefit进行优化但是我在使用lsqcurvefit解算器时出现错误

首先是x变量(t)和y变量(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

现在需要安装的模型

%-----------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');

现在我已经使用了我想要拟合的参数(k1 k2 k3)的初始估计值 并称为解算器

%----------------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)');

以下是我发生的错误

    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] =...

我没有足够的经验知道我可以做什么来进行模型拟合。

是否有任何其他求解器可以帮助我,或者是否有任何全局优化工具箱可以用于初始化值

欢迎任何提示......

1 个答案:

答案 0 :(得分:1)

您缺少一些TOMLAB文件(看起来非常像丢失的许可证文件)。

请确保您完整安装了TOMLAB(由与Mathworks不同的公司销售),然后重试。

作为TOMLAB的替代品,您可以尝试使用Matlab的全局优化工具箱。