Using mean function

7 visualizaciones (últimos 30 días)
Georgios
Georgios el 28 de Mayo de 2011
Hello, I am new to matlab and I try to find a solution to a simple problem I have.
I have a column of values and I want to calculate mean values with a certain step, e.g. calculate the mean of values 1-6, then the mean of values 7-12 etc ...
Can someone please give any ideas on how to do this?
Thank you, George

Respuesta aceptada

Teja Muppirala
Teja Muppirala el 28 de Mayo de 2011
The reshape command can help to implement this:
X = rand(18,1)
Y = reshape(X,6,[])
mean(Y)
or more simply, just:
mean(reshape(X,6,[]))

Más respuestas (2)

bym
bym el 28 de Mayo de 2011
assuming x is the vector:
mean(x(1:7));
mean(x(7:12));

Georgios
Georgios el 28 de Mayo de 2011
Thank you both for your answers. I hadn't thought using the reshape function, it worked fine.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by