Solve nonnegative leastsquares constraints problem
Solves nonnegative leastsquares curve fitting problems of the form
$$\underset{x}{\mathrm{min}}{\Vert C\cdot xd\Vert}_{2}^{2},\text{where}x\ge 0.$$
x = lsqnonneg(C,d)
x = lsqnonneg(C,d,options)
x = lsqnonneg(problem)
[x,resnorm] = lsqnonneg(...)
[x,resnorm,residual] = lsqnonneg(...)
[x,resnorm,residual,exitflag] = lsqnonneg(...)
[x,resnorm,residual,exitflag,output]
= lsqnonneg(...)
[x,resnorm,residual,exitflag,output,lambda]
= lsqnonneg(...)
x = lsqnonneg(C,d)
returns
the vector x
that minimizes norm(C*xd)
subject
to x >= 0
. C
and d
must
be real.
x = lsqnonneg(C,d,options)
minimizes
with the optimization parameters specified in the structure options
.
You can define these parameters using the optimset
function. lsqnonneg
uses
these options
structure fields:
 Level of display. 
 Termination tolerance on 
x = lsqnonneg(problem)
finds the minimum
for problem
, where problem
is
a structure with the following fields:
 Matrix 
 Vector 
 'lsqnonneg' 
 Options structure created using optimset 
[x,resnorm] = lsqnonneg(...)
returns
the value of the squared 2norm of the residual: norm(C*xd)^2
.
[x,resnorm,residual] = lsqnonneg(...)
returns
the residual, dC*x
.
[x,resnorm,residual,exitflag] = lsqnonneg(...)
returns
a value exitflag
that describes the exit condition
of lsqnonneg
:
>0  Indicates that the function converged to a solution 
0  Indicates that the iteration count was exceeded. Increasing
the tolerance ( 
[x,resnorm,residual,exitflag,output]
= lsqnonneg(...)
returns a structure output
that
contains information about the operation in the following fields:


 The number of iterations taken 
 Exit message 
[x,resnorm,residual,exitflag,output,lambda]
= lsqnonneg(...)
returns the dual vector (Lagrange multipliers) lambda
,
where lambda(i)<=0
when x(i)
is
(approximately) 0
, and lambda(i)
is
(approximately) 0
when x(i)>0
.
Compare the unconstrained least squares solution to the lsqnonneg
solution
for a 4by2 problem:
C = [ 0.0372 0.2869 0.6861 0.7071 0.6233 0.6245 0.6344 0.6170]; d = [ 0.8587 0.1781 0.0747 0.8405]; [C\d lsqnonneg(C,d)] = 2.5627 0 3.1108 0.6929 [norm(C*(C\d)d) norm(C*lsqnonneg(C,d)d)] = 0.6674 0.9118
The solution from lsqnonneg
does not fit
as well (has a larger residual), as the least squares solution. However,
the nonnegative least squares solution has no negative components.
[1] Lawson, C.L. and R.J. Hanson, Solving Least Squares Problems, PrenticeHall, 1974, Chapter 23, p. 161.