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 
Return to the default flat view Create a new topic Submit Reply
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
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: Fri Oct 10 12:29:49 PDT 2025

Total time taken to generate the page: 0.07947 seconds