loop for where command [message #43038] |
Wed, 09 March 2005 14:57  |
aswatantran
Messages: 3 Registered: March 2005
|
Junior Member |
|
|
i have an array eg. polygonids[1,1,2,2,3,3,3,4,5,5,5,6,6,7,7,8,8,9,10].
i want to extract all the subscripts which have the same value into
separate arrays
i tried it with the where command in a loop but it doesnt seem to work
because the array has varying dimensions and i would need to create it
at runtime
does anybody have any suggestions on how this can be done
thanks
Anu
|
|
|
Re: loop for where command [message #43185 is a reply to message #43038] |
Thu, 17 March 2005 11:45  |
Benjamin Hornberger
Messages: 258 Registered: March 2004
|
Senior Member |
|
|
anu wrote:
> hi
>
> thanks for the tip .. it works !!
> but i am not able to extract the data further into separate arrays
>
Well, say a is your original array and you could extract all indices of
ones (1's) into the variable "ones_indices" then you can extract them
into a separate array by
ones_array = a[ones_indices]
Of course, if you know that you have "count" ones in your array, this is
equivalent to
ones_array = replicate(1, count)
|
|
|