How to calculate moving average in a matrix?

R
riyanath-seela · May 10, 2022 · 2K views
Question
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).
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Sep 13, 2026

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.

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!