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

Home » Public Forums » archive » Re: XY position of subscripts
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: XY position of subscripts [message #80178 is a reply to message #80171] Fri, 11 May 2012 10:01 Go to previous messageGo to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den fredagen den 11:e maj 2012 kl. 18:02:40 UTC+2 skrev KH:
> On May 11, 11:36 am, Mats Löfdahl <mats.lofd...@gmail.com> wrote:
>> Den fredagen den 11:e maj 2012 kl. 17:14:27 UTC+2 skrev KH:
>>
>>> Hello,
>>> I have a quick question I was hoping to get some help with.
>>
>>> Assuming you have a 2D array and then use WHERE to find specific
>>> subscripts in the array, how can you convert those subscripts into X
>>> and Y coordinates?
>>
>>> I feel like this is something I should know how to do, but I am
>>> drawing a blank right now.
>>> Thanks,
>>> Kim
>>
>> Here's an example:
>>
>> IDL> Ni=10
>> IDL> Nj=20
>> IDL> A=bytarr(Ni,Nj)
>> IDL> A[4,7]=1
>> IDL> indx=where(A eq 1)
>> IDL> print,A[indx mod Ni, indx / Ni]
>>    1
>
> Thanks for the reply, but what I am looking for are the X and Y
> positions of where the array equals 1. So in your example, how would
> I get X=4 and Y=7 from the subscripts generated by the WHERE command?

Those are the indices I used in the last line: indx mod Ni and indx / Ni.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: scalar system variable as single element array
Next Topic: cgplot and the disappearing white axis

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

Current Time: Sat Oct 11 12:26:09 PDT 2025

Total time taken to generate the page: 0.55977 seconds