comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » array 'minus'
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
array 'minus' [message #36090] Mon, 18 August 2003 20:00 Go to next message
tomson is currently offline  tomson
Messages: 39
Registered: March 2003
Member
Hi, I'd like to eliminate some elements in a array. For example,
A=[1,2,3,4,5,6,7,8,9,0]
N=[3,6]
I want to get a array b equal to A but without A(3) and A(6). How to do
that?

Thank you.

Tomson
Re: array 'minus' [message #36167 is a reply to message #36090] Tue, 19 August 2003 17:24 Go to previous messageGo to next message
tomson is currently offline  tomson
Messages: 39
Registered: March 2003
Member
Thanks.

"tomson" <tom2959@21cn.com> д����Ϣ����:bhs3ot$1p1f$1@mail.cn99.com...
> Hi, I'd like to eliminate some elements in a array. For example,
> A=[1,2,3,4,5,6,7,8,9,0]
> N=[3,6]
> I want to get a array b equal to A but without A(3) and A(6). How to do
> that?
>
> Thank you.
>
> Tomson
>
>
Re: array 'minus' [message #36168 is a reply to message #36090] Tue, 19 August 2003 17:24 Go to previous messageGo to next message
tomson is currently offline  tomson
Messages: 39
Registered: March 2003
Member
Thanks.

"tomson" <tom2959@21cn.com> д����Ϣ����:bhs3ot$1p1f$1@mail.cn99.com...
> Hi, I'd like to eliminate some elements in a array. For example,
> A=[1,2,3,4,5,6,7,8,9,0]
> N=[3,6]
> I want to get a array b equal to A but without A(3) and A(6). How to do
> that?
>
> Thank you.
>
> Tomson
>
>
Re: array 'minus' [message #36230 is a reply to message #36090] Thu, 28 August 2003 09:35 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 18 Aug 2003 20:00:03 -0700, tomson wrote:

> Hi, I'd like to eliminate some elements in a array. For example,
> A=[1,2,3,4,5,6,7,8,9,0]
> N=[3,6]
> I want to get a array b equal to A but without A(3) and A(6). How to do
> that?
>

The HISTOGRAM solution is detailed in the tutorial on D. Fanning's site:


Problem: Remove some elements, listed in random order, from a vector.

IDL> vec=randomu(sd,10)
IDL> remove=[3,7,2,8]
IDL> keep=where(histogram(remove,MIN=0,MAX=n_elements(vec)-1) eq 0,cnt)
IDL> if cnt ne 0 then vec=vec[keep]
IDL> print,keep
0 1 4 5 6 9

We've used HISTOGRAM and WHERE to simply generate a list of kept indices.

This method will excel when you have lots of elements to remove, or any
repeated elements.

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: working of the '*' operator in IDL in the context of arrays and matrices
Next Topic: how to make polygons created by idlgrpolygon transparent?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:39:05 PDT 2025

Total time taken to generate the page: 0.00610 seconds