the math of movmean

31 visualizaciones (últimos 30 días)
Muhannad AL-hazmi
Muhannad AL-hazmi el 25 de Mzo. de 2022
Editada: Matt J el 25 de Mzo. de 2022
Hello
how movmean works exactly if movemean(DATA,5) is that means that it will take the first five number and divide it by 5 and then take the next 5 number and divide it by 5 and so on i know that not the case because i calculate it and the numbers didn't match plz help

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Mzo. de 2022
help movmean
Y = movmean(X,K) for a vector X and positive integer scalar K computes
a centered moving average by sliding a window of length K along X. Each
element of Y is the local mean of the corresponding values of X inside
the window, with Y the same size as X. When K is even, the window is
centered about the current and previous elements of X. The sliding
window is truncated at the endpoints where there are fewer than K
elements from X to fill the window.
So it does not take the first 5 and then move over 5 and take those and so on:
[mean(x(1:3))
mean(x(1:4))
mean(x(1:5))
mean(x(2:6))
mean(x(3:7))
....
]
and ending at x(end-2:end)

Más respuestas (1)

Matt J
Matt J el 25 de Mzo. de 2022
Editada: Matt J el 25 de Mzo. de 2022
If if the data looks like,
DATA=[x1,x2,...xn , a,b,c,d,e, y1,y2,....,ym]
then movemean(DATA,5) will replace c with mean([a,b,c,d,e]). In other words, it will center a window of length 5 at the current point and average the elements in that window. For elements near the edge of the array, there will be missing elements. The handling of the missing elements depends on what you give for the 'Endpoints' input parameter.

Categorías

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

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by