[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: drop array elements
Matthew Kay <mwk@crml.uab.edu> writes:
> Hi,
>
> 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'?
The best way to go after this is to rephrase the question so that BP
(b-primed) is the list of rows to *keep*. Then it's easy:
a = a(*,bp)
This, in the end, is what JD was getting after. A way to see this
more clearly might be to do it in steps like this:
tmp = intarr(1024) + 1 ;; Create a mask with all 1's by default
tmp(b) = 0 ;; Zero out the discarded rows
bp = where(tmp EQ 1, ct) ;; Find the kept rows - compute BP
if ct GT 0 then a = a(*,bp) ;; Extract those rows
Good luck,
Craig
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------