Search All of the Math Forum:

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

 Messages: [ Previous | Next ]
 ms Posts: 61 Registered: 11/6/06
Re: Adding point by point using a cell matrix
Posted: Jun 10, 2010 8:16 AM

On Jun 9, 1:47 pm, "sscnekro " <stiahni.m...@zoznam.sk> 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);
end

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
end

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

Date Subject Author
6/9/10 ms
6/9/10 sscnekro
6/9/10 sscnekro
6/10/10 ms
6/10/10 ms
6/10/10 sscnekro
6/13/10 ms
6/14/10 sscnekro
6/14/10 sscnekro
6/14/10 Sebo K