How do i fix this error?

조회 수: 5 (최근 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