Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: concatenate cell array
Date: Wed, 1 Jul 2009 18:44:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 41
Message-ID: <h2gaph$sv6$1@fred.mathworks.com>
References: <h2g8m1$e5k$1@fred.mathworks.com> <h2g9vp$7rm$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246473842 29670 172.30.248.38 (1 Jul 2009 18:44:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 1 Jul 2009 18:44:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1875128
Xref: news.mathworks.com comp.soft-sys.matlab:552127


Unfortunately, I don't know the size before hand.
for ..
    if GOOD
        concatenate A
   end
 end 

If determines whether I should concatenate A 

Diego  


"us " <us@neurol.unizh.ch> wrote in message <h2g9vp$7rm$1@fred.mathworks.com>...
> "Diego Lass" <dlISCool@gmail.com> wrote in message <h2g8m1$e5k$1@fred.mathworks.com>...
> > Hi 
> > I would like to concatenate cell array in a loop
> > 
> > A = {}
> > for ...
> >      if ...
> >          concatenate A
> >       end
> > end
> > 
> > What is the most efficient way to do this?
> > 
> > p.s. I tried A = { A, {new cell array}  }, it did not work. 
> > 
> > Thanks
> > Diego
> 
> one of the solutions
> - iff you know the loop's max...
> 
>      n=5;
>      c=cell(n,1);     % <- preallocation
> for  i=1:n
>      c{i}=rand(1,i);     % <- index into preallocated CELL
> end
> 
> us