"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
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
a=[1 2; 3 4];
b={};
b=cat(1,b,a) %this will concatenat i dim 1
"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
For...
if good
goodCounter = goodCounter + 1;
A{goodCounter} = {new cell};
end
end
Diego
"Ravi " <ravi.chilumula@gmail.com> wrote in message <h2gat9$77g$1@fred.mathworks.com>...
> this shud work..
>
> a=[1 2; 3 4];
> b={};
> b=cat(1,b,a) %this will concatenat i dim 1
>
>
> "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
"Diego Lass" <dlISCool@gmail.com> wrote in message <h2gaph$sv6$1@fred.mathworks.com>...
> Unfortunately, I don't know the size before hand.
> for ..
> if GOOD
> concatenate A
> end
> end
>
> If determines whether I should concatenate A
>
> Diego
one of the solutions is outlined below
c={};
for i=1:n
if bitand(i,1)
c=[c,{i:i}];
end
end
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.