Re: naming elements in an array [message #28947] |
Mon, 21 January 2002 14:26  |
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 #29012 is a reply to message #28947] |
Thu, 24 January 2002 02:06  |
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
> ------------------------------------------------------------ ---------
|
|
|