lsqnonneg
Solve nonnegative linear least-squares problem
Solve nonnegative least-squares curve fitting problems of the form
Syntax
x = lsqnonneg(C,d)
x = lsqnonneg(C,d,options)
x = lsqnonneg(problem)
[x, resnorm残留]= lsqnonneg(___)
[x,resnorm,residual,exitflag,output] = lsqnonneg(___)
[x,resnorm,residual,exitflag,output,lambda] = lsqnonneg(___)
Description
finds the minimum forx
= lsqnonneg(problem
)problem
, whereproblem
is a structure. Create theproblem
argument by exporting a problem from Optimization app, as described inExporting Your Work.
Examples
Input Arguments
Output Arguments
Tips
For problems where
d
has length over 20,lsqlin
might be faster thanlsqnonneg
. Whend
has length under 20,lsqnonneg
is generally more efficient.To convert between the solvers when
C
has more rows than columns (meaning the system is overdetermined),[x,resnorm,residual,exitflag,output,lambda] = lsqnonneg(C,d)
相当于
[m,n] = size(C); [x,resnorm,residual,exitflag,output,lambda_lsqlin] = ... lsqlin(C,d,-eye(n,n),zeros(n,1));
The only difference is that the corresponding Lagrange multipliers have opposite signs:
lambda = -lambda_lsqlin.ineqlin
.
Algorithms
lsqnonneg
uses the algorithm described in[1]. The algorithm starts with a set of possible basis vectors and computes the associated dual vectorlambda
. It then selects the basis vector corresponding to the maximum value inlambda
to swap it out of the basis in exchange for another possible candidate. This continues untillambda ≤ 0
.
References
[1] Lawson, C. L. and R. J. Hanson.Solving Least-Squares Problems. Upper Saddle River, NJ: Prentice Hall. 1974. Chapter 23, p. 161.