lsqcurvefit UseParallel error on matlab 2016b

I am receiving a strange error when trying to use the lsqcurvefit. When executing the following (taken from https://uk.mathworks.com/help/optim/ug/lsqcurvefit.html) I receive an error 'Reference to non-existent field 'UseParallel'.' See below for full error.
Note, I did not receive this error on older version so of Matlab e.g. 2015a.
Code
xdata = ... [0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3]; ydata = ... [455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5];
fun = @(x,xdata)x(1)*exp(x(2)*xdata);
x0 = [100,-1]; x = lsqcurvefit(fun,x0,xdata,ydata)
Full Error:
Reference to non-existent field 'UseParallel'.
Error in computeFinDiffGradAndJac
Error in sfdnls (line 97) computeFinDiffGradAndJac(x,funfcn,confcn,valx, ...
Error in snls (line 179) [A,findiffevals] = sfdnls(xcurr,fvec,Jstr,group,[],funfcn,l,u,...
Error in lsqncommon (line 151) snls(funfcn,xC,lb,ub,flags.verbosity,options,defaultopt,initVals.F,initVals.J,caller, ...
Error in lsqcurvefit (line 257) lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,caller,...
Thanks in advance for your help.

Answers (1)

It sounds to me as if your MATLAB installation is corrupted somehow. Try reinstalling, or at least reinstalling Optimization Toolbox.
If reinstalling does not help, then please contact technical support.
Alan Weiss
MATLAB mathematical toolbox documentation

1 Comment

Hi Alan,
Thanks for the response.
Interestingly, I managed to get this working by explicitly setting the option UseParallel to False:
xdata = ...
[0.9 1.5 13.8 19.8 24.1 28.2 35.2 60.3 74.6 81.3];
ydata = ...
[455.2 428.6 124.1 67.3 43.2 28.1 13.1 -0.4 -1.3 -1.5];
options = optimset('UseParallel', false);
fun = @(x,xdata)x(1)*exp(x(2)*xdata);
x0 = [100,-1];
lb = []
ub = []
x = lsqcurvefit(fun,x0,xdata,ydata,lb,ub,options)
This runs without error producing the following result as expected:
x =
498.8309 -0.1013

Sign in to comment.

Categories

Asked:

on 18 Jan 2017

Commented:

on 19 Jan 2017

Community Treasure Hunt

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

Start Hunting!