File Exchange

image thumbnail


version 1.0 (71.1 KB) by

Non linear Leasr Squares Solver with box constraints/

1 Download


No License

This program has been inspired by LMFsolve File ID: #16063.
On hard problems numerical difficulties may appear. Nlsqbnd comes mainly from a large fortran code written by Lindstrom and Wedin Institute of information processing university of UME, SWEDEN. Some corrections have been done. The interface Nlsqbnd is comptible with the standard calling of Matlab solvers. In particular nlsqbnd can be called exactlly as Lsqnonlin. A test program is included with several problem and results are compared with LMFsolve (with a new output argument for comparison purpose) and lsqnonlin. Nlsqbnd calls Blas and linpack codes. Mex files are provided for 32 and 64 bits windows platform.

Comments and Ratings (3)

N. Shamsundar

N. Shamsundar (view profile)

M. Barraud,

Thanks for this nice contribution. The Elsunc code is quite efficient for NLS problems, but it has one weakness. If derivatives are approximated by finite differences, the code uses

deltaj = max(abs(xtemp), 1.0D0)*delta

in Subroutine JacDif. For problems such as the NIST STRD Hahn1 problem (, in which the fit coefficients are of different orders of magnitude, this simple choice of 'deltaj' causes poor approximation of some components of the Jacobian and results in failure of the solver, which terminates with result code -6.

One solution is to use

deltaj = SIGN(MAX(ABS(xtemp),XSCL(j)),xtemp)*delta

where XSCL is an array of positive scale factors for the model coefficients that the user provides as an option. The default for XSCL can be a vector of all values equal to 1.0.


Fares (view profile)

The mex files are compiled for 32 and 64 bit windows. What operating system is your MATLAB distribution installed on?


can you please suggest why I get the error

??? Undefined function or method 'elsunc' for input arguments of type 'function_handle'.

Error in ==> Nlsqbnd.nlsqbnd at 221

is it a problem accessing the elsunc.mexw64 file? I can't view it.


MATLAB Release
MATLAB 7.5 (R2007b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today