the math of movmean
24 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2022-3-25
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 个评论
更多回答(1 个)
Matt J
2022-3-25
编辑:Matt J
2022-3-25
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!