How do i fix this error?

8 次查看(过去 30 天)
Yusuke
Yusuke 2019-3-17
回答: Stephan 2019-3-17
Here's my code, I'm trying to fit a arctangent function to data,
years = xlsread('C:\Users\a\Desktop\WorldPopulation', 'A1:CO1');
population = xlsread('C:\Users\a\Desktop\WorldPopulation', 'A2:CO2');
x = years.';
y = population.';
FO = fitoptions('Display','iter',...
'StartPoint',[4100 0.02 -39.7 6500],...
'MaxIter','2000',...
'MaxFuncEval','3000');
FT = fittype('a.*atan(c.*x+d)+b', 'options', FO);
[min, gof] = fit(x, y, FT);
But I keep getting the error
Error using curvefit.basefitoptions/set
The name 'Display' is not an accessible property for an instance of class 'basefitoptions'.
Error in fitoptions (line 189)
set(f,varargin{:});
Error in OptimizeCurve (line 15)
FO = fitoptions('Display','iter',...
How do i fix this?

回答(1 个)

Stephan
Stephan 2019-3-17
Hi,
the Display option is only avaiable if the fitting method is nonlinear least squares:
The default Method is 'None' (which appears strange). I would expect, that it works, when you set:
FO = fitoptions('Method', 'NonlinearLeastSquares', 'Display','iter',...
'StartPoint',[4100 0.02 -39.7 6500], 'MaxIter','2000',...
'MaxFuncEval','3000');
Best regards
Stephan

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by