How do i fix this error?
17 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Stephan
on 17 Mar 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
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!