MATLAB: Unexplained error using fitdist with Stable distro – help

fitdistfitdist errorMATLABstable fit

I am receiving an unusual error that I can't decode when using fitdist with the 'Stable' distribution option. I've tried troubleshooting by using different datasets and different distributions; the Normal works on the same data. I've used fitdist for stable distributions many times, though not with this release and not in the past 6 months. I've never encountered this error / difficulty before.
The error is:
"Unrecognized function or variable 'getIpOptions'.
Error in fmincon (line 832)
options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01);
Error in prob.StableDistribution>stablefit (line 1318)
[parmhat,~,err,output] = fmincon(@(params)stable_nloglf(x,params),phi0, …
Error in prob.StableDistribution.fit (line 211)
params = stablefit(x,0.05,opt);
Error in fitdist>localfit (line 245)
pd = feval(fitter,x,'cens',c,'freq',f,varargin{:});
Error in fitdist (line 192)
pd = localfit(dist,fitter,x,cens,freq,args{:});"
Code that works is:
load hospital;
z = hospital.Weights;
pd = fitdist (z,'Normal');
This generates the error:
pd2 = fitdist(z,'Stable');
Is this a bug in r2020a? I have a copy of Nolan's stablefit toolbox and it fits the same data without throwing an error and with the following result:
>> stablefit(z,1,0)
ans =
2.0000 -0.0214 18.6947 154.0000

Best Answer

The error message shows that MATLAB defines a function named stablefit internally for its own use. The definition of stablefit from Nolan's toolbox is also on MATLAB's path. This confuses the MATLAB and MATLAB seems to call the wrong stablefit function. Remove stablefit from Nolan's toolbox from MATLAB's path, and it will probably work fine.