Moving average - MATLAB Cody - MATLAB Central

Problem 44844. Moving average

Difficulty:Rate

A moving average function that returns an array that is equal in length to the input arrays (which can be row or column)

A variable window size, w, whenever possible, i.e.

w = 3;

means to use 3 data points on both sides of the point of interest (averaging 7 points total)

returns a ROW vector of moving average values

The following inputs:

x = [1,2,3,4]; y = [3,5,7,9]; w = 2;

should output:

ys = [3,5,7,9];

The following inputs:

x = [1,2,3,4,5]; y = [2,5.5,6,9.5,10]; w = 3;

should output:

ys = [2,4.5,6.6,8.5,10];

Note: the last test case is meant to be a challenge...

Solution Stats

31.58% Correct | 68.42% Incorrect
Last Solution submitted on Dec 25, 2022

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers5

Suggested Problems

More from this Author1

Problem Tags

Community Treasure Hunt

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

Start Hunting!