the math of movmean
37 views (last 30 days)
Show older comments
Muhannad AL-hazmi
on 25 Mar 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
0 Comments
Accepted Answer
Walter Roberson
on 25 Mar 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)
0 Comments
More Answers (1)
Matt J
on 25 Mar 2022
Edited: Matt J
on 25 Mar 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.
0 Comments
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!