Hi all,

Is there a smarter way to extract a 2D subset of a 2D matrix than in the following example?

The problem is that I have to know the number of lines and cols of the subset for the reshape....

perldl> $x = sequence(10,2)
perldl> p $x
[
 [ 0  1  2  3  4  5  6  7  8  9]
 [10 11 12 13 14 15 16 17 18 19]
]
perldl> $ind = whichND(($x>3) & ($x<18))
perldl> p $ind
[
 [4 0]
 [5 0]
 [6 0]
 [7 0]
 [8 0]
 [9 0]
 [0 1]
 [1 1]
 [2 1]
 [3 1]
 [4 1]
 [5 1]
 [6 1]
 [7 1]
]
perldl> $y = $x->range($ind)->reshape(7,2)
perldl> p $y
[
 [ 4  5  6  7  8  9 10]
 [11 12 13 14 15 16 17]
]

Cheers,
Bruno
--
____________________________________________________
Dr. Bruno Picard

CLS
Dir. Océanographie Spatiale, Dép. Traitement de la Mesure et Segment Sol
Space Oceanography Division, Data Analysis and Ground Processing Unit

8-10 rue Hermès, 31520 Ramonville Saint Agne, France
Tél: (+33)5.61.39.37.37 Fax: (+33)5.61.39.37.82
[EMAIL PROTECTED] http://www.cls.fr
http://www.jason.oceanobs.com (aviso site)
http://www.ipcc.ch
____________________________________________________

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to