How do i fix this error?

3 Ansichten (letzte 30 Tage)
Yusuke
Yusuke am 17 Mär. 2019
Beantwortet: Stephan am 17 Mär. 2019
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?

Antworten (1)

Stephan
Stephan am 17 Mär. 2019
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

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by