Non-negative results when solving a set of equations

Francesco Potorti` Potorti at isti.cnr.it
Thu Jun 5 01:43:35 CDT 2008


>> I have a set of equations (Ax = b) that I can solve with  A\b.
>> However, due to physical reasons, the result can not contain negative values
>> (they should be zero in that case). I went through the manual and did a
>> search, but found nothing that could help me.

That depends on what you want.  If you want to "solve" the equations,
there is nothing to do, because you hav a single solution, provided that
A is non-singular.

If you want simply to set negative values to zero, you do:
x=A\b; x(x<0)=0;

>If you are not satisfied with simply setting the negative components of
>the solution to zero, look for function lsqnonneg.

Interesting.  Is there a free implementation for Octave?

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: Potorti at isti.cnr.it
(entrance 20, 1st floor, room C71)     Web:   http://fly.isti.cnr.it/


More information about the Help-octave mailing list