Variable 'a' is type integer.
If you try
ncl > a=(/1,2,3,2,1,2,1,2,4,3,1,2/)
ncl > print(a<3)
; all integers
(0) 1
(1) 2
(2) 3
(3) 2
(4) 1
(5) 2
(6) 1
(7) 2
(8) 3
(9) 3
(10) 1
(11) 2
ncl > a(a<3)=0
Takes the a<3 integers and uses them as subscripts
and sets them to zero.
-- It only works for integers. Try ncl > b=(/1,2,3,2,1,2,1,2,4,3,1,2/)*1.0 ncl > q= b<3 ncl > print(q) Variable: q Type: float <************* Total Size: 48 bytes 12 values Number of Dimensions: 1 Dimensions and sizes: [12] Coordinates: (0) 1 (1) 2 (2) 3 (3) 2 (4) 1 (5) 2 (6) 1 (7) 2 (8) 3 (9) 3 (10) 1 (11) 2 ncl > print(b(b<3)) or ncl > print(b(q)) fatal:Illegal subscript. Vector subscripts must be integer On 3/20/12 9:41 PM, Chuliang Xiao wrote: > Dear NCL users, > some confusion about the following codes > >a=(/1,2,3,2,1,2,1,2,4,3,1,2/) > >a(a<3)=0 > >print(a) > (0) 1 > (1) 0 > (2) 0 > (3) 0 > (4) 1 > (5) 2 > (6) 1 > (7) 2 > (8) 4 > (9) 3 > (10) 1 > (11) 2 > Best regards > ------------------------------------------------------------------------ > Dr. Chuliang XIAO(肖楚良) > School of Atmospheric Sciences, > Nanjing University, > No. 22 Hankou Road, Nanjing 210093, China > Tel: +86-138-0514 5653 > Email: xiaocl@smail.nju.edu.cn <mailto:xiaocl@smail.nju.edu.cn> > > > _______________________________________________ > ncl-talk mailing list > List instructions, subscriber options, unsubscribe: > http://mailman.ucar.edu/mailman/listinfo/ncl-talk _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Tue Mar 20 21:55:16 2012
This archive was generated by hypermail 2.1.8 : Tue Mar 27 2012 - 08:50:24 MDT