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 #36086 is a reply to message #36085] Mon, 18 August 2003 23:13 Go to previous messageGo to previous message
tianyf_cn is currently offline  tianyf_cn
Messages: 19
Registered: November 2002
Junior Member
There are a few ways to do this.
1).Replace A(N) with -1 and then use Where() function to find
those elements that are not equal to -1.
A(N)=-1
b=A(where(A ne -1))

2). A more generic method to delete specified element(s) of an array.
Here we need some user-supplied function - del_ind. The function is given below.
b=del_ind(A,N)
***
;+
; Name:
; del_ind
;
; Purpose:
; To delete specified elements of an array.
;
;+++
;-

function del_ind, array, toDel
tmp=lonarr(n_elements(array))
tmp(todel)=-1
return,array(where(tmp ne -1))
end
;///


Tian.

"tomson" <tom2959@21cn.com> wrote in message news:<bhs3ot$1p1f$1@mail.cn99.com>...
> 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?
>
> Thank you.
>
> Tomson
[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:19:08 PDT 2025

Total time taken to generate the page: 0.00363 seconds