From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Preallocate when you don't know the size of a matrix
Date: Fri, 20 May 2011 16:09:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 4
Message-ID: <ir63n1$55g$>
References: <ir636l$3pm$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1305907745 5296 (20 May 2011 16:09:05 GMT)
NNTP-Posting-Date: Fri, 20 May 2011 16:09:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1895050
Xref: comp.soft-sys.matlab:727892

"Javier " <> wrote in message <ir636l$3pm$>...
> Hi, I'm going to fill a matrix but I don't have any idea of its final size. Is it efficient to preallocate with zeros (X,X) being X a large number and then delete the zeros that stay?  Thank you!

Could you give a little more detail, and possibly some sample code?  Depending on the setup, a cell array might make sense.  Or if you have R2011a, it might not matter (since they did some optimization in the non-preallocated case).  But we need more info than what you've given us.