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

Home » Public Forums » archive » Re: naming elements in an array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: naming elements in an array [message #28947] Mon, 21 January 2002 14:26 Go to next message
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
M wrote:
>
> Hi all,
> I've just written a routine which returns a single column matrix array of 14
> elements - what I'd like to do is to assign individual names to each value,
> so they can be called in calculations later on.
>
> Does anyone know how I can do this? (Apologies if this is a 'trivial'
> problem - I'm currently trying to teach myself the world if IDL, with not
> too much success!)
>
> Thanks for your time,
>
> Manish

Shouldn't be too hard. What about this?

zero = 0
one = 1
two = 2
three = 3
..
thirteen = 13

Now you can reference your array with my_array(nine) to get the tenth
element.

Or what about :-

the_median = my_array(0)
the_sum = my_array(1)
tenth_percentile = my_array(2)
etc

Is that what you mean? Or do you just want to access the values via a
loop :-

For i = 0,13 Do Begin
value = my_array(i)
;do some gonculations on value
End

HTH,

Andrew

------------------------------------------------------------ ---------
Andrew D. Cool .->-.
Electromagnetics & Propagation Group `-<-'
Surveillance Systems Division Transmitted on
Defence Science & Technology Organisation 100% recycled
PO Box 1500, Salisbury electrons
South Australia 5108

Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ ---------
Re: naming elements in an array [message #28955 is a reply to message #28947] Tue, 22 January 2002 02:59 Go to previous messageGo to next message
the_cacc is currently offline  the_cacc
Messages: 104
Registered: October 2001
Senior Member
"M" <mrmanish@bigfoot.com> wrote in message news:<a2hlpj$d7h$1@yarrow.open.ac.uk>...
> I've sorted this (very simple!) problem now, no need to reply!
>
> Thanks,
>
> M.


Oh, but we *want* to reply. So how did you fix it ? [Please say you
used a structure...]
Re: naming elements in an array [message #28960 is a reply to message #28947] Mon, 21 January 2002 10:15 Go to previous messageGo to next message
Manish is currently offline  Manish
Messages: 20
Registered: April 2001
Junior Member
I've sorted this (very simple!) problem now, no need to reply!

Thanks,

M.




> Hi all,
> I've just written a routine which returns a single column matrix array of
14
> elements - what I'd like to do is to assign individual names to each
value,
> so they can be called in calculations later on.
>
> Does anyone know how I can do this? (Apologies if this is a 'trivial'
> problem - I'm currently trying to teach myself the world if IDL, with not
> too much success!)
>
> Thanks for your time,
>
> Manish
>
>
Re: naming elements in an array [message #29012 is a reply to message #28947] Thu, 24 January 2002 02:06 Go to previous message
Manish is currently offline  Manish
Messages: 20
Registered: April 2001
Junior Member
Cheers people, I realised you can reference the nth element in an array by
arrayname[n-1].
Quite a simple problem, which I realised the answer to straight after
posting and then was highly embarrassed at it's simplicity!

thanks for your help though, it's appreciated as I delve into the unfamiliar
world of IDL!

M.



"Andrew Cool" <andrew.cool@dsto.defence.gov.au> wrote in message
news:3C4C9599.AD9D0885@dsto.defence.gov.au...
>
>
> M wrote:
>>
>> Hi all,
>> I've just written a routine which returns a single column matrix array
of 14
>> elements - what I'd like to do is to assign individual names to each
value,
>> so they can be called in calculations later on.
>>
>> Does anyone know how I can do this? (Apologies if this is a 'trivial'
>> problem - I'm currently trying to teach myself the world if IDL, with
not
>> too much success!)
>>
>> Thanks for your time,
>>
>> Manish
>
> Shouldn't be too hard. What about this?
>
> zero = 0
> one = 1
> two = 2
> three = 3
> ..
> thirteen = 13
>
> Now you can reference your array with my_array(nine) to get the tenth
> element.
>
> Or what about :-
>
> the_median = my_array(0)
> the_sum = my_array(1)
> tenth_percentile = my_array(2)
> etc
>
> Is that what you mean? Or do you just want to access the values via a
> loop :-
>
> For i = 0,13 Do Begin
> value = my_array(i)
> ;do some gonculations on value
> End
>
> HTH,
>
> Andrew
>
> ------------------------------------------------------------ ---------
> Andrew D. Cool .->-.
> Electromagnetics & Propagation Group `-<-'
> Surveillance Systems Division Transmitted on
> Defence Science & Technology Organisation 100% recycled
> PO Box 1500, Salisbury electrons
> South Australia 5108
>
> Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
> Email : andrew.cool@dsto.defence.gov.au
> ------------------------------------------------------------ ---------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: problems producing a colobar
Next Topic: Re: Widget backgrounds

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

Current Time: Wed Oct 08 14:56:42 PDT 2025

Total time taken to generate the page: 0.00516 seconds