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 #36478 is a reply to message #36472] Wed, 24 September 2003 09:17 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 23 Sep 2003 20:21:44 -0700, 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
>
> Reimar

But this is also slow, since you reallocate the array on each iteration
(which starts to hurt when the array gets large). Far better is to
pre-allocate the array to roughly the correct size, and grow it as
necessary. Search this newsgroup for "Is there a standard 'null' array"
for a thread on this very topic.

JD
[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:10:21 PDT 2025

Total time taken to generate the page: 0.56085 seconds