Non-negative results when solving a set of equations

Terje Hansen T.A.r.hansen at tue.nl
Thu Jun 5 07:34:08 CDT 2008


On 5 Jun 2008, at 08:43, Francesco Potorti` wrote:

>>> 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;
>

The solutions have a physical meaning. If one or more are zero, then  
these are not present physically in the system, and they have to be  
excluded. However, in that case the other values could change also,  
since one or more components are not present.



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



More information about the Help-octave mailing list