|
Re: Resizing arrays [message #45554 is a reply to message #45552] |
Wed, 21 September 2005 11:32  |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Well, in 2D the equivalent would be to remove rows/columns that are all
zero. TOTAL(ABS()) should do the trick. Haje
"Benjamin Luethi" <luethi@phim.unibe.ch> wrote in message
news:op.sxgpyegso9wlc0@elara...
> Hi,
>
> for a 1D-array that has at least 1 element different from 0:
> nonzero_values = values[where(values ne 0)]
>
> for 2D/3D/...-arrays it's not so simple and you need to give an
> example of what you want to do...
>
> Ben
>
> On Tue, 20 Sep 2005 22:03:34 +0200, Julio <julio@cpa.unicamp.br> wrote:
>
>> Hello,
>>
>> I have a simple question... I have an array, and inside it I have some
>> zero values. I want to resize the array, cutting off the zero values. I
>> want to keep only positive values in the new array.
>>
>> How can I do that... I know it is very simple, but I could not do that.
>> :-(
>>
>> Thanks,
>> Julio
>>
>
>
>
> --
> -------------+
|
|
|
Re: Resizing arrays [message #45556 is a reply to message #45554] |
Wed, 21 September 2005 10:09  |
Benjamin Luethi
Messages: 22 Registered: December 2004
|
Junior Member |
|
|
Hi,
for a 1D-array that has at least 1 element different from 0:
nonzero_values = values[where(values ne 0)]
for 2D/3D/...-arrays it's not so simple and you need to give an
example of what you want to do...
Ben
On Tue, 20 Sep 2005 22:03:34 +0200, Julio <julio@cpa.unicamp.br> wrote:
> Hello,
>
> I have a simple question... I have an array, and inside it I have some
> zero values. I want to resize the array, cutting off the zero values. I
> want to keep only positive values in the new array.
>
> How can I do that... I know it is very simple, but I could not do that.
> :-(
>
> Thanks,
> Julio
>
--
-------------+
|
|
|
Re: Resizing arrays [message #45574 is a reply to message #45556] |
Tue, 20 September 2005 13:29  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
> I have a simple question... I have an array, and inside it I have some
> zero values. I want to resize the array, cutting off the zero values. I
> want to keep only positive values in the new array.
IDL> a = [0, 1, 2, 0, 1, 2]
IDL> b = a[where(a gt 0)]
IDL> print, b
1 2 1 2
-Mike
|
|
|