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

Home » Public Forums » archive » Re: null array
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: null array [message #36480 is a reply to message #36479] Wed, 24 September 2003 06:52 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Ben Panter wrote:
>
> Reimar Bauer wrote:
>> Tomson wrote:
>>
>>
>>> Hi, I need a null array without any elements in it. Then elements will be
>>> added to it. But how to define a null array?
>>>
>>> Best
>>> Tomsom
>>
>>
>> What is this? I don't use matlab.
>>
>> Would you like to do something like this.
>>
>> if n_elements(array) eq 0 then array=scalar else array=[array,scalar]
>>
>> Or in a loop
>>
>> for i=0,10 do begin
>> ..
>>
>> if i eq 0 then array=scalar else array=[array,scalar]
>> endfor
>
> I'm a bit worried about showing my ignorance here - but rather than have
> an 'if' running on every iteration, could you not do:
>
> a=[0.5]
>
> for i=0,n do begin
> ..
> endfor
>
> a=a[1:*]
>
> cutting out n if evaluations for the sake of 1 array crop?

Yep - I do that often. Not just in IDL either.

BTW, getting back to the original question, isn't every variable that hasn't yet been
defined in an IDL procedure (an infinite number to be sure) a null array? :o\

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to read the data like this?
Next Topic: Programming ENVI

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

Current Time: Fri Oct 10 05:11:10 PDT 2025

Total time taken to generate the page: 0.48282 seconds