Re: the dimension of array [message #27302] |
Tue, 16 October 2001 20:30 |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
From: "jiali" <jiali3@21cn.com>
> Hi, I ofter use the following operation:
> a=fltarr(10,10,10) is a 3-d array,
> if I set
> b=a(0,*,*), it is still a 3-d array. But I hope b is a 2-d
> array. How can I do then?
Use REFORM. From the documentation:
"The REFORM function changes the dimensions of an array without changing the
total number of elements. If no dimensions are specified, REFORM returns a
copy of Array with all dimensions of size 1 removed..."
For example
IDL> a = fltarr(10,10,10)
IDL> b = a[0,*,*]
IDL> c = reform(b)
IDL> help, a, b, c
A FLOAT = Array[10, 10, 10]
B FLOAT = Array[1, 10, 10]
C FLOAT = Array[10, 10]
---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
|
|
|