# Re: drop array elements

```"J.D. Smith" wrote:
>
> Matthew Kay wrote:
> >
> > Would anyone have any suggestions for an easy way
> > to drop elements in an array? For example, say 'a'
> > is a 14x1024 array and 'b' is a 1x25 array of row
> > indicies  in 'a' that should be dropped. Is there
> > a simple command for re-assigning 'a', without the
> > 25 rows indicated in 'b'?
> >
> a=a[*,where(histogram(b,MIN=0,MAX=(size(a,/DIMENSIONS))[1]-1,BINSIZE=1) eq 0)]
>
> The real meat here is finding a list of indices which do not contain the
> elements of b.  There are many ways to do this, but this is a fast one.

I just *had* to understand this one. Here's another way of implementing
this method:

;- Get number of rows in a
dims = (size(a, /dimensions))[1]

;- Create index array for rows of a (1=keep the row, 0=discard the row)
index = replicate(1L, nrows)
index[b] = 0L

;- Locate the indices of rows we wish to keep
keep = where(index eq 1)

;- Extract the rows we wish to keep
a = (temporary(a))[*, keep]

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley

```