# Solving overdeterminated linear equation system with specified conditions

3 visualizzazioni (ultimi 30 giorni)
Thomas il 12 Mar 2012
Dear fellows! I´m new in the world of matlab and i´d like to solve the following overdeterminated system of linear equations with lsqr-method.
A*p=b
where A is a (5x3) matrix, p=[p1;p2;p3] and b is vector with 5 given vector elements.
without any conditions i could solve the system with p=A\b or p=lsqr(A,b).
BUT following conditions have to be achivied for solving the problem
1. p1;p2;p3 are always >=0
2. p1+p2+p3=sum(p)=1
Does sombody can help me to set the conditions for the solving process?
best regards Thomas
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Seth DeLand il 12 Mar 2012
Hi Thomas, If you have the Optimization Toolbox, LSQLIN can solve constrained least-squares problems: http://www.mathworks.com/help/toolbox/optim/ug/lsqlin.html
You can use the A and b arguments to enforce that p1; p2; p3 >= 0 and the Aeq and beq arguments to enforce that p1+p2+p3 = 1.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Thomas il 14 Mar 2012
Did i define the constraints correct for following settings?
(C(5x3)matrix, d(5x1)vector) and C*x=d)
where
lb=zeros(3,1); %x1,x2,x3>=0
Aeq=ones(1,3);beq=1; %x1+x2+x3=1
[x,resnorm,residual,exitflag,output]=lsqlin(C,d,[],[],Aeq,beq,lb);
best regards
Thomas

Accedi per commentare.

### Categorie

Scopri di più su Systems of Nonlinear Equations in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by