Unexpected result from lsqlin
Afficher commentaires plus anciens
Recently I encountered an unexpecte result from lsqlin. Basically I have a linear system that can be any size, even 1x1. This is actually the case of interest. I attach the code:
s=[7.46355685131195e-06;2.61224489795918e-07;-7.46355685131195e-06;2.61224489795918e-07;0;0;0;0;0;0;0;0;0;0;2.61224489795918e-07;1.21904761904762e-08;-2.61224489795918e-07;6.09523809523810e-09;0;0;0;0;0;0;0;0;0;0;-7.46355685131195e-06;-2.61224489795918e-07;1.49271137026239e-05;0;-7.46355685131195e-06;2.61224489795918e-07;0;0;0;0;0;0;0;0;2.61224489795918e-07;6.09523809523810e-09;0;2.43809523809524e-08;-2.61224489795918e-07;6.09523809523810e-09;0;0;0;0;0;0;0;0;0;0;-7.46355685131195e-06;-2.61224489795918e-07;1.49271137026239e-05;0;-7.46355685131195e-06;2.61224489795918e-07;0;0;0;0;0;0;0;0;2.61224489795918e-07;6.09523809523810e-09;0;2.43809523809524e-08;-2.61224489795918e-07;6.09523809523810e-09;0;0;0;0;0;0;0;0;0;0;-7.46355685131195e-06;-2.61224489795918e-07;1.49271137026239e-05;0;-7.46355685131195e-06;2.61224489795918e-07;0;0;0;0;0;0;0;0;2.61224489795918e-07;6.09523809523810e-09;0;2.43809523809524e-08;-2.61224489795918e-07;6.09523809523810e-09;0;0;0;0;0;0;0;0;0;0;-7.46355685131195e-06;-2.61224489795918e-07;1.87420339044574e-05;8.27690603250169e-08;-1.12784770531454e-05;3.43993550120935e-07;0;0;0;0;0;0;0;0;2.61224489795918e-07;6.09523809523810e-09;8.27690603250169e-08;2.61795472287276e-08;-3.43993550120935e-07;6.99453551912568e-09;0;0;0;0;0;0;0;0;0;0;-1.12784770531454e-05;-3.43993550120935e-07;1.74696244982844e-05;-1.13373307789508e-07;-6.19114744513898e-06;2.30620242331427e-07;0;0;0;0;0;0;0;0;3.43993550120935e-07;6.99453551912568e-09;-1.13373307789508e-07;2.54432097407122e-08;-2.30620242331427e-07;5.72706935123043e-09;0;0;0;0;0;0;0;0;0;0;-6.19114744513898e-06;-2.30620242331427e-07;1.23822948902779e-05;-2.91167575618666e-22;0;0;0;0;0;0;0;0;0;0;2.30620242331427e-07;5.72706935123043e-09;-2.91167575618666e-22;2.29082774049217e-08];
z=[-8287.20136961842;-207.695733121256;-7600.97514253616;-534.391927360151;-5646.81895072033;-842.926473299020;-2749.01799205948;-608.263953041959;-1800.96549474418;-218.233277809774;-1246.61121855062;-222.701572169097;-454.985962888617;-229.489284788134;-207.695733121258;-4.31159651230973;-211.583072054673;-10.5817786869719;-207.469127449374;-19.4084812806167;-205.554052675241;-14.2334094340071;-127.980376432081;-5.82044377019796;-89.3993392954632;-10.0358904762527;-38.6028133285081;-12.8937660172881;-7600.97514253634;-211.583072054673;-6704.83421266254;-532.664018086793;-4247.04164361325;-784.667235831777;-374.396860142614;-575.355545468737;-646.254735224021;-237.767202031333;-565.502081093624;-211.802648689606;-245.788051294455;-215.794095284558;-534.391927360146;-10.5817786869719;-532.664018086794;-24.4250894201275;-533.575869722970;-44.6885886888697;-562.261663238565;-27.6728741709106;-340.294987483632;-3.91648028872448;-233.005638525614;-13.8504678942122;-98.9719393675175;-19.5724723345471;-5646.81895072033;-207.469127449374;-4247.04164361319;-533.575869722965;-874.961989329080;-681.827735041812;4550.00831251650;-524.710100984108;1754.26594854213;-278.456336087023;813.872071787322;-192.126815096214;174.918786479950;-186.341242826303;-842.926473299020;-19.4084812806167;-784.667235831777;-44.6885886888698;-681.827735041812;-73.1296054491854;-560.603026422607;-44.4867666242581;-367.876515600137;-5.36578138470502;-262.187708991285;-13.9626208876454;-116.168335764689;-19.6047309183772;-2749.01799205944;-205.554052675241;-374.396860142644;-562.261663238565;4550.00831251667;-560.603026422608;12023.7350216699;-465.718352496805;5337.97747610125;-338.507025489656;2511.57328179486;-178.101015182985;439.839230323449;-183.023532525701;-608.263953041959;-14.2334094340071;-575.355545468737;-27.6728741709106;-524.710100984101;-44.4867666242582;-465.718352496805;-15.3539182495451;-359.289436100471;17.6126762396493;-285.779177534844;7.60510383356906;-145.366784817360;0.0955479313669716;-1800.96549474418;-127.980376432081;-646.254735224029;-340.294987483632;1754.26594854214;-367.876515600137;5337.97747610143;-359.289436100471;2994.26975751692;-289.642137402146;1958.78945016873;-162.344662349205;811.528922972301;-119.802928873498;-218.233277809774;-5.82044377019797;-237.767202031333;-3.91648028872449;-278.456336087023;-5.36578138470502;-338.507025489655;17.6126762396493;-289.642137402146;35.6258773907798;-248.235934165285;25.5115603160600;-137.758663681854;17.5455698744229;-1246.61121855062;-89.3993392954633;-565.502081093631;-233.005638525614;813.872071787326;-262.187708991284;2511.57328179485;-285.779177534844;1958.78945016873;-248.235934165288;1588.04981195810;-144.928904474322;800.700832420902;-94.0273547749384;-222.701572169097;-10.0358904762527;-211.802648689606;-13.8504678942122;-192.126815096214;-13.9626208876454;-178.101015182985;7.60510383356905;-162.344662349205;25.5115603160600;-144.928904474323;20.8134206727082;-85.8545148794237;15.3928444934107;-454.985962888616;-38.6028133285082;-245.788051294462;-98.9719393675172;174.918786479950;-116.168335764689;439.839230323450;-145.366784817360;811.528922972296;-137.758663681854;800.700832420902;-85.8545148794237;488.887846553582;-53.5142394051840;-229.489284788134;-12.8937660172881;-215.794095284558;-19.5724723345471;-186.341242826303;-19.6047309183772;-183.023532525701;0.0955479313669731;-119.802928873498;17.5455698744229;-94.0273547749366;15.3928444934106;-53.5142394051840;10.5398416193868];
A=s'*s;
b=s'*z;
L=-3e10;
U=1e10;
x1=lsqlin(A,b,[],[],[],[],L,U);
x2=b/A;
disp(A*x1-b)
disp(A*x2-b)
Since the matrix A is actually a scalar, the solution can be computed also as b/A. Accidentally, b/A is also compliant to the lower and upper bound L and U, so I'm wondering why does lsqlin return a different solution. I use matlab 2015b with optimization toolbox 7.3. I thank you very much in advance.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Linear Least Squares dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!