Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
calculating mean of matrixes

Subject: calculating mean of matrixes

From: Sandra

Date: 8 Jul, 2011 19:01:10

Message: 1 of 3

Hello everyone,

I have three matrixes 349x277, I would like to calculate the elementwise mean of those three matrixes.

So if I had:
A=
     3 3 1
     4 1 4

B =

     1 2 4
     2 3 1

I would want:
mean=
     2 2.5 2.5
     3 2 2.5

Sorry for asking something that basic, but I can figure out how to tell matlab to take the average elementwise...

Any help is greatly appreciated
Sandra

Subject: calculating mean of matrixes

From: Sandra

Date: 8 Jul, 2011 19:18:10

Message: 2 of 3

"Sandra" wrote in message <iv7k5m$2en$1@newscl01ah.mathworks.com>...
> Hello everyone,
>
> I have three matrixes 349x277, I would like to calculate the elementwise mean of those three matrixes.
>
> So if I had:
> A=
> 3 3 1
> 4 1 4
>
> B =
>
> 1 2 4
> 2 3 1
>
> I would want:
> mean=
> 2 2.5 2.5
> 3 2 2.5
>
> Sorry for asking something that basic, but I can figure out how to tell matlab to take the average elementwise...
>
> Any help is greatly appreciated
> Sandra

I figured it out myself..sorry I m an idiot..I just couldnt think of it...:

mean = ((a+b)./(2));

sorry again..

Subject: calculating mean of matrixes

From: Sean de

Date: 8 Jul, 2011 20:11:10

Message: 3 of 3

"Sandra" wrote in message <iv7l5i$560$1@newscl01ah.mathworks.com>...
> "Sandra" wrote in message <iv7k5m$2en$1@newscl01ah.mathworks.com>...
> > Hello everyone,
> >
> > I have three matrixes 349x277, I would like to calculate the elementwise mean of those three matrixes.
> >
> > So if I had:
> > A=
> > 3 3 1
> > 4 1 4
> >
> > B =
> >
> > 1 2 4
> > 2 3 1
> >
> > I would want:
> > mean=
> > 2 2.5 2.5
> > 3 2 2.5
> >
> > Sorry for asking something that basic, but I can figure out how to tell matlab to take the average elementwise...
> >
> > Any help is greatly appreciated
> > Sandra
>
> I figured it out myself..sorry I m an idiot..I just couldnt think of it...:
>
> mean = ((a+b)./(2));
>
> sorry again..

Don't overwrite the builtin (and very useful) function 'mean'.

my_mean = (a+b)./2

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us