MATLAB Answers


lsqlin ignores monotonicity constraints for polynomial fit.

Asked by Oliver
on 19 Sep 2013
Latest activity Answered by Matt J
on 12 Oct 2017

I'm trying to solve a system Ax = b using lsqlin, where A = [P T] and x =[p; t] and P(rho) is a high order (~10) polynomial with the parameters p. So I use

s = lsqlin(A,b);

and the solver works as expected. This also works when I use some dummy constraints in order to force lsqlin to use qpsub.

Now I want to constrain the polynomial to be monotonic in the range 0 < rho < MAX, so I use the constraint Cx < 0 with C = [-dP 0] and where dP is the derivative of P. This constraint matrix has a few thousand rows so I cover the whole range of rho. Now I use

s = lsqlin(A,b,C,Zeros);

but the resulting polynomial is not monotonic. Checking if the constraints have been met


several of the values are > 0, violating the constraints.

The only warning I receive is regarding the usage of the medium scale algorithm and according to the lambda.ineqlin output the solution does not lie on a boundary.

What could cause lsqlin to ignore constraints without giving a warning?


Log in to comment.

1 Answer

Answer by Matt J
on 12 Oct 2017

The correct test is C*s>TolCon.


Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today