[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generally accessing the rest of the elements in an array
- Subject: Re: Generally accessing the rest of the elements in an array
- From: thompson(at)orpheus.nascom.nasa.gov (William Thompson)
- Date: 21 Feb 2001 00:12:20 GMT
- Newsgroups: comp.lang.idl-pvwave
- Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov)
- References: <96uslb$ges$1@ra.nrl.navy.mil>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:23597
"tbowers" <tbowers@nrlssc.navy.mil> writes:
>How do I access the 2nd + dimensions of an array generally, without knowing
>the
>number of higher dims this array has. E.g. say a is a 3 column by
>n-dimensional
>aray, and n is unknown. Here, I'll define it as:
>a = indgen(3,2,4)
>I want the equivalent of (in this case):
>b = (a[0,*,*])^2 + (a[1,*,*])^2 + (a[2,*,*])^2
(rest deleted)
You should be able to do something like the following:
b = a[0,*,*,*,*,*,*,*]^2 + a[1,*,*,*,*,*,*,*]^2 + a[2,*,*,*,*,*,*,*]^2
even though A might not have so many dimensions. With your above example, you
would then get
IDL> help,b
B INT = Array[1, 2, 4]
William Thompson