Back Home Up Next

Subchapters:

Working with arrays

The size function return information on the size(s) and type of the arrays, and the n_elements will just return the total number of element in an array:

        IDL> print,size(tab1)
                       2           3           3           4           9

Here 2 is the number of dimension, 3 and 3 are the number of rows and columns, 4 indicates the type of data (here floating point) and 9 is the total number of elements, also available by:

        IDL> print,n_elements(tab1)
                       9

You can perform operations on the arrays WITHOUT using loops:

        IDL> vec2 = vec1^2
        IDL> print,vec2
                   1       4       9      16       9       4       9      16      25
                  25       9
        IDL> print,cos(tab1)
                0.0707372    -0.416147    -0.989992
                -0.416147    -0.989992    -0.653644
                 0.753902    -0.911130      1.00000
        IDL> vec3 = vec2 - vec1
        IDL> print,vec3
                   7      63       4      50       0       2       3       3       1
                   0       2
        IDL> vec4 = [ vec3, 2 , 3]

 

IDL courses C. Morisset 2004 IA/UNAM V 2.2

Back Home Up Next