[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: minimum real number from a list of complex numbers
From: |
Ben Abbott |
Subject: |
Re: minimum real number from a list of complex numbers |
Date: |
Fri, 29 Oct 2010 18:08:54 +0800 |
On Oct 29, 2010, at 5:50 PM, Robert Patterson wrote:
> Hi,
>
> I have a list of numbers (the roots of a list of quadratic equations)
> that represent the times at which two particles collide. Some
> collisions are impossible so that times have imaginary components. I
> want to find the lowest purely real number from the list without writing
> explicit loops.
>
> For example from
> v=[1, 2, 2+1i, 0 + 1i]
> I want to find 1.
>
> Does anyone have a good idea? I cannot see how to use isreal() for this
> purpose.
>
> Thanks
>
> Robert
Try
min (v(imag(v)==0))
Ben