Q:

A moving average of a data set x = {x1, x2, x3, x4, …, xn} is defined as a set of averages of subsets of the original data set. For example, a moving average of every two terms would be 1/2 *{x1+ x2, x2+ x3, x3 + x4, …, xn-1 + xn}

0

A moving average of a data set x = {x1, x2, x3, x4, …, xn} is defined as a set of averages of subsets of the original data set. For example, a moving average of every two terms would be 1/2 *{x1+ x2, x2+ x3, x3 + x4, …, xn-1 + xn}. Write a function that will receive a vector as an input argument, and will calculate and return the moving average of every two elements.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

moveAve2.m

function moveave = moveAve2(vec)

% Calculates the moving average of every 2

% elements of a vector

% Format of call: moveAve2(vector)

% Returns the moving average of every 2 elements

firstpart = vec(1:end-1);

secondpart = vec(2:end);

moveave = 0.5 * (firstpart + secondpart);

end

Eliminating or reducing noise is an important aspect of any signal 

processing. For example, in image processing noise can blur an 

image. One method of handling this is called median filtering.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now