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

Home » Public Forums » archive » Re: 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 #36088 is a reply to message #36087] Mon, 18 August 2003 22:09 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
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?

Well, you could do this:

B = make_array(size(A, /DIMENSIONS), VALUE=1B)
B[N] = 0B

A = A[where(B)]

The first two statements construct a mask array, B, with the same
dimensions as A. The elements of B are set equal to 1 (true) when we
wish to retain the corresponding element of A and 0 (false) otherwise.
The final statement generates a 1D array containing only those elements
of A that are flagged in B as true. If there are no true elements in B
it will generate an error.

Also I suggest you specify

compile_opt STRICTARRSUBS

at the beginning of your routine or code block (as long as you are using
a version that supports it: 5.6 or greater, I think). This will ensure
that subscripting B with out-of-bounds values on N will raise an error.

--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help with EOS_GD_INTERPOLATE
Next Topic: IDL authors - get cracking!

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

Current Time: Wed Oct 08 17:34:19 PDT 2025

Total time taken to generate the page: 0.00474 seconds