MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: extract only positive solutions


sol = {{-.532, .932}, {.34, 23}};

Select[sol, And @@ Positive[#] &]

{{0.34, 23}}

Cases[sol, _?(And @@ Positive[#] &)]

{{0.34, 23}}

Cases[sol, {_?Positive ..}]

{{0.34, 23}}

DeleteCases[sol, {___, _?NonPositive, ___}]

{{0.34, 23}}

DeleteCases[sol, _?(Or @@ NonPositive[#] &)]

{{0.34, 23}}


Bob Hanlon


On Fri, Feb 17, 2012 at 6:23 AM, Gabby Domingo <gbdomingo at gmail.com> wrote:
> hi all! how do you extract only positive solutions to a solver, like
> NSolve?
>
> sol={{-.532,.932},{.34,23}}
>
> and extract {.34,.23}?
>



  • Prev by Date: Re: Documentation for GridBoxSpacings
  • Next by Date: Re: extract only positive solutions
  • Previous by thread: extract only positive solutions
  • Next by thread: Re: extract only positive solutions