Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 使用lsqcurvefit在曲线拟合中选择x0(x的初始点)_Matlab - Fatal编程技术网

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

Matlab 使用lsqcurvefit在曲线拟合中选择x0(x的初始点),matlab,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

我想将任意函数((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值

如果我理解正确,你会得到不同的C值,这取决于你对初始x0的选择,你想知道如何选择一个好的初始值。 这是一个很难回答的问题,如果你没有足够的知识来理解你试图拟合的函数。它描述的是实验数据吗?如果是的话,你应该对x的近似值有一些期望。 但很可能是方程没有唯一解,或者解算器陷入局部极小值