使用lsqcurvefit选择曲线拟合中的x0(x的初始点)

时间:2014-09-10 11:28:40

标签: matlab

我想拟合一个任意函数((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值

1 个答案:

答案 0 :(得分:1)

如果我理解正确,您可以根据您选择的初始x0获得不同的c值,并且您需要有关如何选择良好初始值的建议。 如果没有足够的知识来解决你想要适应的功能,这是很难回答的。它描述的是实验数据吗?如果是这样,你应该对x应该是什么有一些期望。 但很有可能的情况是,你的方程没有唯一的解决方案,或者解算器陷入局部最小值。

相关问题