【问题标题】:nlinfit in MatLab receives an unexpected resultMatLab 中的 nlinfit 收到意外结果
【发布时间】:2017-11-12 02:24:07
【问题描述】:

我第一次遇到的测验给了我一个 Logistic 模型:

并要求我对其进行线性化,然后根据它给出的数据评估ak的值(在本主题中L被视为3000)。我完成了,但在第二个主题中遇到了麻烦,它要求我对第一个主题中评估的 ak 的值进行非线性回归。这是我的代码:

function y = func(const, t)
  y = const(1)./(1 + const(2)*exp(-const(3)*t));
end

t = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
y = [43.65,   109.86,   187.21,  312.67,   496.58,  707.65 ,  ... 
     960.25,  1238.75,  1560,    1824.29,  2199,    2438.89,  2737.71];

yAss = log ((3000 ./ y) - 1);
p    = polyfit (t, yAss, 1);
a    = exp (1) ^ (p(2)); 
k    = -p(1);

beta0 = [3000, a, k];
beta  = nlinfit (t, yAss, @func, beta0);

yAfter   = beta(1) ./ (1 + beta(2) * exp (-beta(3) * t));
yCompare = 3000 ./ (1 + a * exp (-k * t));

scatter (t, y); hold on;
plot (t, yAfter, 'r');
plot (t, yCompare);

它给出了什么:

红色曲线是用nlinfit返回的值生成的,谁能告诉我哪里错了?

【问题讨论】:

    标签: matlab regression non-linear-regression


    【解决方案1】:

    我觉得自己很愚蠢...回答我自己的问题,而问题本身也很愚蠢...

    beta  = nlinfit (t, yAss, @func, beta0);
    

    应该是:

    beta  = nlinfit (t, y, @func, beta0);
    

    我真的想删除那个问题...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-09
      • 1970-01-01
      • 2012-08-18
      • 2013-04-04
      • 2017-04-07
      • 2021-05-08
      相关资源
      最近更新 更多