MATLAB Answers

why lsqlin constraint, lsqnonneg do not answer correctly

4 views (last 30 days)
Mohammadjavad Shokriafra
Mohammadjavad Shokriafra on 21 Jun 2020
Answered: Matt J on 23 Jun 2020
I have a sparse matrix C(1500*1500) and d(1500*1) and constraint lb=zeros(1500,1), ub=ones(1500,1).
I can solve this system of linear equations by C\d very easily, but in some cases due to the negative results, I can not use that anymore. I found that I can use "lsqlin" or "lsqnonneg" to solve my problem, However, these functions do not have same (reasonable) results. I mean in cases that C\d gives reasonable results, the lsqlin and lsqnonneg have no resonable results.
For example I show some results for each function.
C\d: 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07 9.9e-07
lsqlin: 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07 5.0e-07
lsqnonneg: 7.9e-07 5.6e-07 7.8e-07 6.0e-07 0 8.0e-07 6.8e-07 2.8e-07 6.3e-07 3.7e-07 3.4e-07 9.6e-07 9.5e-07 8.7e-07 0 0 0
Does anyone know how can I use these functions and have reasonable results?
Thanks

  0 Comments

Sign in to comment.

Answers (1)

Matt J
Matt J on 23 Jun 2020
To get reasonable results, the problem needs to have a reasonable solution.

  0 Comments

Sign in to comment.