using lsqlin when you have a large matrix
Mostrar comentarios más antiguos
hi,
Can someone please tell me how to correct the following code.
x = [yt,r];
a = eye(2);
b = zeros(2,1);
opts = optimset('lsqlin');
opts.LargeScale = 'off';
opts.Display = 'none';
coef = lsqlin(x,yt2,-a,-b);
My x is a 1000*2 matrix. so i get an error. I read the help for that but couldn't understand it clearly.
thanks.
Respuesta aceptada
Más respuestas (1)
If you have 1000 unknowns why is "a" only 2x2?
Also, since your constraints are only lower bounds on the unknowns, use the lb input argument instead of A,b
Also, since you only have positivity constraints, consider using LSQNONNEG instead of LSQLIN.
6 comentarios
dav
el 18 de Feb. de 2013
Editada: Walter Roberson
el 18 de Feb. de 2013
Walter Roberson
el 18 de Feb. de 2013
Even if you only have two constraints that you want to actively make use of, you need to supply values for the others, possibly "inf".
Matt J
el 18 de Feb. de 2013
is there any way to correct that code?
As I already mentioned, it is an error to use a 2x2 matrix a=eye(2) and 2x1 vector b=zeros(2,1) when you have more than 2 unknowns.
Teja Muppirala
el 18 de Feb. de 2013
There are not 1000 unknowns, there are only 2. It only seems that way because what the documentation refers to as A, is being called x here, and what the doc refers to as x, is being called coef.
Teja Muppirala
el 18 de Feb. de 2013
Oops I meant C, not A.
Matt J
el 18 de Feb. de 2013
There are not 1000 unknowns, there are only 2.
Ah well. The question has been edited.
Categorías
Más información sobre Linear Least Squares en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!