f



Accessing individual contents of cell array for large amount of cells

I have data thats in a cell in form of doubles, and depending on the data set, the length of this cell can range from about 20 to over 100. I need to access the contents of this cell array individually. I know how I can do this using deal, as in the example from doc:

[a,b,c,d] = deal(C{:})

My question: is there a method for automatically creating an array like [trial1 trial2 trial3 ... trial99] for varying lengths (that are specific to the cell length, of course) without actually doing it manually each time?

Sorry if it's confusing...

Thanks in advance!

Ashley
0
Ashley
4/9/2010 8:22:04 PM
comp.soft-sys.matlab 211071 articles. 13 followers. lunamoonmoon (258) is leader. Post Follow

3 Replies
681 Views

Similar Articles

[PageSpeed] 8

"Ashley " <namehere@thisplace.com> wrote in message <hpo29c$n7l$1@fred.mathworks.com>...
> I have data thats in a cell in form of doubles, and depending on the data set, the length of this cell can range from about 20 to over 100. I need to access the contents of this cell array individually. I know how I can do this using deal, as in the example from doc:
> 
> [a,b,c,d] = deal(C{:})
> 
> My question: is there a method for automatically creating an array like [trial1 trial2 trial3 ... trial99] for varying lengths (that are specific to the cell length, of course) without actually doing it manually each time?

No. The actual data in each of the cells is physically in different parts of memory. When you concatenate some or all of them into a single variable you have to copy all of the individual data contents into a new single block of memory. That can only be done by manually doing it each time.  The alternative is to copy *everything* to one array and then access slices of that array. This latter approach has the advantage that it will ultimately will be faster to access your data this way than concatenating the individual cells each time.

James Tursa
0
James
4/9/2010 8:44:05 PM
"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <hpo3il$d9o$1@fred.mathworks.com>...
> "Ashley " <namehere@thisplace.com> wrote in message <hpo29c$n7l$1@fred.mathworks.com>...
> > I have data thats in a cell in form of doubles, and depending on the data set, the length of this cell can range from about 20 to over 100. I need to access the contents of this cell array individually. I know how I can do this using deal, as in the example from doc:
> > 
> > [a,b,c,d] = deal(C{:})
> > 
> > My question: is there a method for automatically creating an array like [trial1 trial2 trial3 ... trial99] for varying lengths (that are specific to the cell length, of course) without actually doing it manually each time?
> 
> No. The actual data in each of the cells is physically in different parts of memory. When you concatenate some or all of them into a single variable you have to copy all of the individual data contents into a new single block of memory. That can only be done by manually doing it each time.  The alternative is to copy *everything* to one array and then access slices of that array. This latter approach has the advantage that it will ultimately will be faster to access your data this way than concatenating the individual cells each time.
> 
> James Tursa


Thanks, you've saved me a few hours. 

I actually separated the data and put them into nonuniform cells (that's the only way I know how to separate data based on something without having to do it for each new data set) based on the trial number, so i'd like to keep the data separated because I need to manipulate the data within a trial - separate from the other trials. Is there a more efficient way of doing this?

*fyi: trial - from doing a repeated task

Thanks in advance!

Ashley
0
Ashley
4/9/2010 10:37:03 PM
"Ashley " <namehere@thisplace.com> wrote in message <hpoa6f$l41$1@fred.mathworks.com>...

> Thanks, you've saved me a few hours. 
> 
> I actually separated the data and put them into nonuniform cells (that's the only way I know how to separate data based on something without having to do it for each new data set) based on the trial number, so i'd like to keep the data separated because I need to manipulate the data within a trial - separate from the other trials. Is there a more efficient way of doing this?
> 
> *fyi: trial - from doing a repeated task
> 
> Thanks in advance!
> 
> Ashley

I found a way to extract it to a double in separate columns. Problem solved!

Ashley
0
Ashley
4/12/2010 4:39:05 PM
Reply: