curve-fitting problem: Unrecognized option name 'showstatus' in OPTIMSET ?

Hi all,
I'm having problems fitting a custom model because I keep getting an error message I don't know what to do about.
I have vector data X and vector data Y, and I want to curve-fit (nonlinearleastsquares) a custom equation.
Here's a snippet of code:
given: independent data vector X, dependent data vector Y
fo=fitoptions('Method', 'NonlinearLeastSquares', 'StartPoint', [1, 4]);
g = fittype( @(a, b, x) a*((x-b).^2), 'options', fo)
[fitobject,gof,output] = fit(X, Y, g);
This generates an error message:
Error using fit>iFit (line 340)
Unrecognized option name 'showstatus'. See OPTIMSET for possibilities.
Error in fit (line 108)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
I have used curve-fitting with library models without any problems. The error occurs when I try to fit a custom model.
Can anyone help?
Thanks,
Andy

15 Comments

Hmmm. Can't seem to reproduce that (in R2018a),
a=1;b=2;
X=linspace(0,1,100).';
Y=a*(X-b).^2;
fo=fitoptions('Method', 'NonlinearLeastSquares', 'StartPoint', [1, 4]);
g = fittype( @(a, b, x) a*((x-b).^2), 'options', fo)
[fitobject,gof,output] = fit(X, Y, g);
>> fitobject
fitobject =
General model:
fitobject(x) = a*((x-b).^2)
Coefficients (with 95% confidence bounds):
a = 1 (1, 1)
b = 2 (2, 2)
Which release? I get no issues with the above code with R2017b...
>> X=1:10;X=X(:);Y=rand(size(X));
>> fo=fitoptions('Method', 'NonlinearLeastSquares', 'StartPoint', [1, 4]);
>> g = fittype( @(a, b, x) a*((x-b).^2), 'options', fo)
g =
General model:
g(a,b,x) = a*((x-b).^2)
>> [fitobject,gof,output] = fit(X, Y, g);
>> fitobject
fitobject =
General model:
fitobject(x) = a*((x-b).^2)
Coefficients (with 95% confidence bounds):
a = 0.04691 (0.009478, 0.08434)
b = 5.02 (3.443, 6.596)
>>
Thank you Matt, dpd. I get the error message with your code snippets as well.
I've literally copied&pasted Matt's code and I get the same error as before.
here is my version info:
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.4.0.813654 (R2018a)
MATLAB License Number: 860095
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 17134)
Java Version: Java 1.8.0_144-b01 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.4 (R2018a)
Control System Toolbox Version 10.4 (R2018a)
Curve Fitting Toolbox Version 3.5.7 (R2018a)
DSP System Toolbox Version 9.6 (R2018a)
Data Acquisition Toolbox Version 3.13 (R2018a)
Global Optimization Toolbox Version 3.4.4 (R2018a)
Image Processing Toolbox Version 10.2 (R2018a)
Instrument Control Toolbox Version 3.13 (R2018a)
Mapping Toolbox Version 4.6 (R2018a)
Neural Network Toolbox Version 11.1 (R2018a)
Optimization Toolbox Version 8.1 (R2018a)
Signal Processing Toolbox Version 8.0 (R2018a)
Statistics and Machine Learning Toolbox Version 11.3 (R2018a)
Symbolic Math Toolbox Version 8.1 (R2018a)
Wavelet Toolbox Version 5.0 (R2018a)
Please copy/paste the full error message. The part you posted doesn't show the full stack of function calls. Also, show us the output of
which -all fit
here is the output you asked for, after running your code snippet:
which -all fit
C:\Program Files\MATLAB\R2018a\toolbox\curvefit\curvefit\fit.p
C:\Program Files\MATLAB\R2018a\toolbox\stats\stats\@gmdistribution\fit.m % gmdistribution method
C:\Program Files\MATLAB\R2018a\toolbox\curvefit\curvefit\fit.m % Shadowed
How do I expand the error message?
This a screenshot of my command line space:
screenshot.jpg
Run the code in a script, not from the command line. Better yet, run it inside a function. If you do, you will see a longer stack of errors including the top level function, e.g.,
Error using fit>iFit (line 135)
X and Y must have the same number of rows.
Error in fit (line 108)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
Error in test (line 8)
[fitobject,gof,output] = fit(X(1:end-1), Y, g);
OK. I've put your code snippet into a function called 'test'. Here is the screenshot of the outcome:
screenshot2.jpg
Hmmm. Very puzzling. Oh well, when in doubt...reboot.
Peculiar! Everything with fit looks OK...altho it's in the options object that the issue lies in that the field name isn't being recognized. So, what does
which -all fitoptions
show?
If I use optimget() on the object a 'showstatus' property isn't shown nor is it documented in the fitoptions function doc, at least on R2017b. Nor do I see such a Name,Value pair in current doc https://www.mathworks.com/help/curvefit/fitoptions.html?s_tid=doc_ta#namevaluepairarguments
Peculiar, indeed to have generated such a reference...that Matt didn't find same issue on another install or R2018a is most peculiar, indeed. Almost looks like there must be some as-yet unimplemented new code in your function that isn't supposed to be able to be executed or the build included code not intended. Just bizarre...
I supposed you have tried the expedient of
clear all
and a restart of new MATLAB session to see is symptom would heal itself...
Complete reboot of my computer, start Matlab again, run test code... same error, :-(
I've looked into the fit.m code. iFit is an internal function declared within the fit.m code.
line 340 deals with an error message function, and the commentary seems to say that it handles exceptions coming out of "LSQNCOMMON", so it seems that the error message that I get is actually generated in that piece of code...?
I've located that script in toolbox\shared\optimlib. Explored the code, but not clear where this error message can be coming from within that. Certainly no mention of "showstatus" anywhere, unless this error message comes from some other code nested further in...?
Try rerunning the code after
>> dbstop if caught error
a Google search on "showstatus" throws up lots of connections to Java. It's ofcourse a pretty generic parameter name, but I notice that Java is also listed in my Matlab version information (see screenshot earlier in this thread).
I don't have Java installed on my machine in any other capacity I'm aware of...
Is there some link between curve-fittinf and Java?
OK, I tried the debub stop, see here screenshot with outcome:
screenshot3.jpg
Not much more informative, unfortunately...
But that does show that the property name 'showstatus' was somehow passed to the optimget routine and as doc shows, there isn't any such property.
Now, how that got generated as a parameter is the kicker...perhaps there is some sort of namespace resolution thingie going on and it did somehow get into a ML object when should have been calling some Java method--TMW has got everything so entwined now it's impossible to know just what might end up using it.
You could just confirm the input arguments to the function when in debug mode, but backtracking to how that got generated is, as you say, probably only something the developers can manage.
Looks like time for an official bug report to me...

Sign in to comment.

Answers (2)

Matt J
Matt J on 21 Jun 2019
Edited: Matt J on 21 Jun 2019
Not much more informative, unfortunately...
But now that you've trapped the error with dbstop you can dbup and dbdown through the call stack and investigate how that call was made...
Personally, I wonder why any code in R2018a is using optimset. It should be deprecated in that version in favor of optimoptions. I begin to wonder if code from a previous partially uninstalled version of Matlab has made its way into the mix. A complete, clean reinstall of Matlab might be necessary. "Clean" means you delete the entire R2018a install folder before re-installing.

2 Comments

"I wonder why any code in R2018a is using optimset. It should be deprecated in that version in favor of optimoptions"
But, TMW has made such a convoluted mess out of all these it's impossible to know what is/isn't "the right stuff!" The doc for optimset says optimoptions is recommended instead of optimset for all solvers except fzero, fminbnd, fminsearch, and lsqnonneg" until they've changed their tune in current release. It's absolutely impossible to keep up... :(
To make it even worse, optimset and optimoptions are defined for the optimization routines in the Optimization Toolbox; fit and fitoptions belong to their own TB and have a different class name.
It's just a proverbual bollux of competing stuff stumbling all over itself. There doesn't seem to be any one coherent design for Matlab at all, any more...
Not sure if this is helpful, but I had the same error. It had something to do with one of the custom subroutines included in my PATH. When I revised everything in PATH to just the basics, custom fitting worked fine.

Sign in to comment.

Thanks J.D.; yes I found the same resolution: I removed all my own scripts and functions from the PATH and then it worked. I must have had a .m file in there with the same name as something in this OPTIMSET thing (though I certainly didn't have a script or function called "showstatus"...)

Products

Release

R2018a

Asked:

on 21 Jun 2019

Answered:

on 19 Feb 2023

Community Treasure Hunt

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

Start Hunting!