How to calculate moving average in a matrix?
5 次查看(过去 30 天)
显示 更早的评论
Hi Guys, I have got a matrix :378x9. I need to calculate the moving average with a window size of 120(starting from row one). Can somebody help me please? By the way, i need to do it also for the covariance(i mean,"A MOVING COVARIANCE). Thank you very much Andrea
2 个评论
Joseph Cheng
2015-10-8
is this a window of 120x9 or are you looking to perform the averaging window per column.
采纳的回答
Image Analyst
2015-10-8
编辑:Image Analyst
2015-10-8
Try conv2:
kernel = ones(120,1)/120;
output = conv2(yourSignal, kernel, 'valid');
Since the window does not leave the boundaries of your signal, of course the output signal will not have as many elements as your input signal.
更多回答(1 个)
Grzegorz Knor
2017-4-7
1 个评论
Image Analyst
2017-4-7
True, and it offers some edge handling options ('shrink', 'discard', 'fill') that conv2() does not have.
conv2() also does not require any toolboxes because it's in base MATLAB.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Gaussian Process Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!