The Math Forum

Search All of the Math Forum:

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

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

Topic: Adding point by point using a cell matrix
Replies: 9   Last Post: Jun 14, 2010 11:10 AM

Advanced Search

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

Posts: 61
Registered: 11/6/06
Re: Adding point by point using a cell matrix
Posted: Jun 10, 2010 8:16 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Jun 9, 1:47 pm, "sscnekro " <> wrote:
> > point by point mean of each row such that I end up with a new cell
> > that is 1x3.

> Hi, I imagine you want to compute something like moving averages? Will some of this be helpful?
> % original cell array
> a = cell(4,3);
> for ii =  1:(size(a,1)  * size(a,2));
> a{ii} = rand(150,1);
> end
> % ultimate cell array
> for ii = 1:size(a,2);
> new_cell{ii} = mean(a{ii});
> end
> % a small hint for the rest of your work, check out what this line gives
> a{3}(3,1)
> BTW, I think there was an unanswered post of yours a few days ago. Did you find the way out? Good luck.

Thank you for the response, but I don't know if that is exactly what I
am looking for. I am trying to get the point by point mean of the
different cells in the same column, rather than single value mean of
all three cells. I basically would like to do something like this,
but was wondering if there was a better way, say using cellfun or
something like that:

a = cell(4,3);%original cell
for ii = 1:(size(a,1) * size(a,2));%for loop to fill up cells so
that they have 150x1 double in them
a{ii} = rand(150,1);

new_cell=cell{1,3}%new cell created to store the point by point mean

for zz=1:3%for loop to fill the point by point mean for each column of
the original cell 'a'
new_cell{1,zz}=(a{1,zz}+a{2,zz}+a{3,zz}+a{4,zz})/4;%point by point
addtion then divided by 4 to get the mean

I was wondering if there is anything better/easier? Thanks!

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2017. All Rights Reserved.