From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: very large array
Date: Mon, 24 Jun 2013 16:14:47 -0500
Organization: NNTP Server
Lines: 25
Message-ID: <kqacqp$oci$>
References: <kq9hdf$bsa$> <kq9khs$kvi$> <kq9n1f$smu$> <kq9nib$12h$> <kq9r5n$21t$> <kq9s1d$d8p$>
NNTP-Posting-Host: jy+QfeYoQFMk8Or4YOj/
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20120306 Thunderbird/3.1.20
X-Notice: Filtered by postfilter v. 0.8.2
Xref: comp.soft-sys.matlab:798130

On 6/24/2013 11:27 AM, Lorenzo Quadri wrote:

> Thanks for your answer :), I'm actually decreasing the variable i
> (certainly not in that piece of code that I posted for example excuse me
> for such example :)) )

Oh...ok.  Can only comment on what can see... :)

> Seems to me that in reality it takes a a lot to
> decrease the array, it seems that every time rebuilds the index or a
> sort of it.

That's a figment of Matlab's memory allocation and being interpreted 
rather than compiled altho you'd have to do things carefully or the 
compiler would have to be able to "see" and recognize a final memory 
reallocation could wait until the end instead of "squeezing" the empty 
memory out on each pass through the loop.

As noted, the way would be to use the logical addressing instead of the 
loop altho that gets again back to how well the compiler can avoid 
unneeded moves.