关于lsqcurvefit拟合的问题-matlab我使用lsqcurvefit函数,对一系列的数据进行方程拟合最优值,但是提示Local minimum possible.lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 08:00:12

关于lsqcurvefit拟合的问题-matlab我使用lsqcurvefit函数,对一系列的数据进行方程拟合最优值,但是提示Local minimum possible.lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is
关于lsqcurvefit拟合的问题-matlab
我使用lsqcurvefit函数,对一系列的数据进行方程拟合最优值,但是提示
Local minimum possible.
lsqcurvefit stopped because the final change in the sum of squares relative to
its initial value is less than the default value of the function tolerance.
可以运行出结果,但是感觉不太对.
请问怎样解决?
附近中有我的数据和代码,
所用公式为
result=-G + aG+r0*exp(e0(1/(15+46.02)-1/(T+46.02)))
想要拟合得到a、r0、e0.G、T、result已知,在数据中分别是第一、二、三列.
我的代码:
clc
clear
getfilename=ls('.\*.xls'); %读取文件列表
filename=cellstr(getfilename); %转换为cell格式
num_of_files=length(filename);
paras0=[3;3;200];
result=[];
paras1=[];
for i=1:num_of_files
database(i)=struct('Name',filename(i),'Data',xlsread(filename{i}));
b=database(i).Name;
b_name=cellstr(b);
dat=database(i).Data;
[x,y]=size(dat);
xdata=[];
ydata=[];
%设置输入参数xdata和输出参数ydata
xdata(:,1) = dat(:,1); %xdata第一列为GPP
xdata(:,2) = dat(:,2); %xdata第二列为空气温度Ta
ydata(:,1) = dat(:,3); %ydata为输出的参量NEE
%进行拟合计算
paras=lsqcurvefit(@myfun,paras0,xdata,ydata);
paras1=paras';
%设置输出值
result_name(i,1)=b_name;
result=[result;paras1]; %#ok
end
xlswrite('结果.xls',result);
xlswrite('结果顺序.xls',result_name);
function f=myfun(paras,xdata)
f = -xdata(:,1)+paras(1).*xdata(:,1)+paras(2).*exp(paras(3)*(1/61.02-1./(xdata(:,2)+46.02)));
我的数据:
2.13984
29.80419
-2.13984
1.895173
29.22398
-1.89517
2.085606
28.32292
-2.0856
2.159606
27.75833
-2.1596
2.707552
26.92917
-2.70755
3.215198
26.74896
-3.2152

关于lsqcurvefit拟合的问题-matlab我使用lsqcurvefit函数,对一系列的数据进行方程拟合最优值,但是提示Local minimum possible.lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is
从你提供的拟合函数来看,其拟合函数是非线性函数.所以用lsqcurvefit()函数是不合理的,应用 nlinfit(()函数来解决.