【问题标题】:select the x0 (initial point for x ) in the curve fitting with lsqcurvefit使用 lsqcurvefit 在曲线拟合中选择 x0(x 的初始点)
【发布时间】:2014-11-04 00:46:31
【问题描述】:

我想拟合任意函数 ( (k_plus-k_t*(1-exp(-k_plus/(a*k_t+b*k_d)))-k_d*(exp(-k_plus/(a*k_t+b *k_d)) 到我的数据集。因此,我在 MATLAB 中使用了 lsqcurvefit。 代码如下:

clc;
clear all;
close all;
%% assign the anon function to a handle
k_plus =[0.1 0.2 0.4 0.7 1 1.1 1.2 1.5 1.7 2 2.5 3 3.5 4 5];
K_minus_d = [0.1 0.2 0.4 0.7 1 1.1 1.2 1.5 1.7 2 2.5 3 3.5 4 5];
K_minus_t =[ 0.1 0.2 0.4 0.7 1 1.1 1.2 1.5 1.7 2 2.5 3 3.5 4 5];
f1= sprintf('table%02d.txt',1);
data=tblread(f1);
x1=data(:,1);
x1=x1';
F=@(c,xdata)(xdata-K_minus_t*(1-exp(-xdata/(c(1)*K_minus_t+c(2)* K_minus_d)))- K_minus_d*(exp(-xdata/(c(1)*K_minus_t+c(2)* K_minus_d)))
x0 = [0.1 0.1];
[c,resnorm,~,exitflag,output] = lsqcurvefit(F,x0,k_plus,x1)
figure;
hold on
plot(k_plus,x1,'r-', 'LineWidth', 1)
plot(k_plus,F(c,k_plus),'-b*','LineWidth', 1,'MarkerSize', 1)
hold off
grid on; 

我想知道如何选择 x0(x 的初始点),因为我在更改 C 时得到了不同的值

【问题讨论】:

    标签: matlab


    【解决方案1】:

    如果我对您的理解正确,您会得到不同的 c 值,具体取决于您对初始 x0 的选择,并且您需要有关如何选择好的初始值的建议。 如果没有充分了解您要适应的功能,这是很难回答的。它是在描述实验数据吗?如果是这样,您应该对 x 应该是什么有一些期望。 但很有可能您的方程没有唯一解,或者求解器陷入局部最小值。

    【讨论】:

      猜你喜欢
      • 2014-03-29
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多