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 #36089 is a reply to message #36088] Mon, 18 August 2003 20:13 Go to previous message
mperrin+news is currently offline  mperrin+news
Messages: 81
Registered: May 2001
Member
tomson <tom2959@21cn.com> 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 can do something like this, using Craig Markwardt's CMSET_OP.PRO:

index_a = indgen(n_elements(a))
index_minus = cmset_op(index_a, "and",/not2,N)
b = a[index_minus]

Just bear in mind there are probably more memory-efficient ways of doing this,
if you're dealing with huge arrays. For anything under a few hundred thousand
elements, the above should work just fine.

- Marshall
[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:24:25 PDT 2025

Total time taken to generate the page: 0.00378 seconds