Search code examples
matlabcurve-fittingdata-fittingmatlab-compiler

Why does the function lsqcurvefit not seem to work in Matlab 2015b?


I am using Matlab 2015b and the function lsqcurvefit does not seem to work. In fact, get the following error message

Diagnostic Information:
Feature: Optimization_Toolbox
License path:
/home/username/.matlab/R2015b_licenses:/.netmount/app/MATLAB/R2015b/licenses/license.dat:/.netmount/app/MATLAB/R2015b/licenses/license.lic:/.netmount/app/MATLAB/R2015b/licenses/network.lic

Licensing error: -18,147.

Error in test (line 7)
x = lsqcurvefit(fun,x0,xdata,ydata)

for the script below. Note that no error message appears when I comment out the last line with lsqcurvefit. Interestingly, the script works nicely in another machine with Matlab 2017a.

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)

Any thoughts please? Thanks


Solution

  • The command lsqcurvefit is not part of MATLAB, it's part of the add-on product Optimization Toolbox. It looks like your 17b installation has that product, but your 15b installation does not, so you're getting an error telling you that you don't have a license for the product.