comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: where help
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: where help [message #7971 is a reply to message #7900] Wed, 29 January 1997 00:00 Go to previous messageGo to previous message
gunter is currently offline  gunter
Messages: 13
Registered: October 1996
Junior Member
David Fanning (davidf@dfanning.com) wrote:

[snip...snip]

: data = FINDGEN(12)
: data = REFORM(data, 3, 4)
: PRINT, data
: 0.00000 1.00000 2.00000
: 3.00000 4.00000 5.00000
: 6.00000 7.00000 8.00000
: 9.00000 10.0000 11.0000
: s = SIZE(data)
:
: OK, suppose I now do this:
:
: index = WHERE(data EQ 6)
:
: The WHERE function returns the 1D index into the 2D array.
:
: PRINT, index
: 6
:
: So, the number 6 is located in index 6 (the 7th number in
: the array with zero-based subscripting). What is its
: 2D subscript? Well, if I divide index by how many columns
: there are in the array, and then take the whole part of that
: number, I will know its row number. In IDL terms:
:
: row = FIX(FLOAT(index)/s(1))
: PRINT, row
: 2

Is there a reason you wouldn't just write: row=index/s(1)? In this manner you
will end up with the whole part automatically.


: To find the column number, I multiply the row number times
: the number of columns in the array, and subtract that value
: from the index. Again, in IDL terms:
:
: col = index - (row * s(1))
: PRINT, col
: 0

And you could just as well write: col = index MOD s(1), where the MOD function
returns the remainder of the division (index/s(1)). Of course there may be
extra time involved (looking up the MOD function, etc) versus the above line.

--
david gunter
http://www.mcs.anl.gov/people/gunter/
-------------------------------------
"When you are a Bear of Very Little Brain, and you Think of Things, you find
sometimes that a Thing which seemed very Thingish inside you is quite
different when it gets out into the open and has other people looking at it."
- A.A. Milne, "The House At Pooh Corner"
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Title , multiple Plot in IDL
Next Topic: Title , multiple Plot in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Tue Dec 02 09:25:10 PST 2025

Total time taken to generate the page: 0.08301 seconds