IDL sumation over given dimension

来源:互联网 发布:微信摇一摇比赛软件 编辑:程序博客网 时间:2024/06/09 14:59

The results are different when a multi-dimensional array is used:

; Define a multi-dimensional array:A = FINDGEN(5,5); Sum each of the rows in A:SUMROWS = TOTAL(A, 1); Sum each of the columns in A:SUMCOLS = TOTAL(A, 2); Print the results:PRINT, 'A = ', APRINT, 'Sum of each row:', SUMROWSPRINT, 'Sum of each column:', SUMCOLS

IDL prints:

A = 0.000000   1.00000   2.00000   3.00000   4.00000
    5.00000    6.00000   7.00000   8.00000   9.00000
    10.0000    11.0000   12.0000   13.0000   14.0000
    15.0000    16.0000   17.0000   18.0000   19.0000
    20.0000    21.0000   22.0000   23.0000   24.0000
 
Sum of each row:  10.0000  35.0000  60.0000  85.0000  110.000
 
Sum of each column:  50.0000  55.0000  60.0000  65.0000  70.0000
0 0
原创粉丝点击