Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Sum of cell array
Replies: 1   Last Post: Aug 2, 2012 9:32 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,710
Registered: 7/26/08
Re: Sum of cell array
Posted: Aug 2, 2012 9:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Antonio Valentine" <chanloha@gmail.com> wrote in message <jvd7jr$pqc$1@newscl01ah.mathworks.com>...
> Hello I have less experince in using the cell array before. I need some help.
>
> Here it goes,
>
> I have a cell array "D" like this.
> {29x10 cell} {40x10 cell}
> {37x10 cell} []
>
> Each element

> >> D{1,1}{1:10,10} % go for 10 arrays.
> ans =
> 0 0 0
> ans =
> 0 0 0
> ans =
> 0 0 0
> ans =
> 0 0 0
> ans =
> 0 3 0
> ans =
> 0 0 0
> ans =
> 0 7 0
> ans =
> 0 0 0
> ans =
> 0 0 0
> ans =
> 6 6 6
>
> I want to keep the results to only 1 variable e.g., D_temp{1,1}{1,1} = [6 16 6].
>
> Basically, I want to have a summation along the dimension "c" -- {a,b}{c,d}.
>
> What are the function should I use including all the statiscal functions too.


None, you have to convert to numerical ARRAY:

% Sum C
A = cat(1, D{1,1}{1:10,10});
S = sum(A,1)

Or use FOR-LOOP if you stick to CELL.

Bruno



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.