why lsqlin constraint, lsqnonneg do not answer correctly

2 次查看(过去 30 天)
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

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Linear Least Squares 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by