Cody

Solution 1722092

Submitted on 6 Feb 2019 by Alfonso Nieto-Castanon
  • Size: 57
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = 0:7; y = 2*x; w = 3; ys = movingAverage(x,y,w); assert(isequal(ys,y))

2   Pass
x = 0:9; y = exp(0.1*x)'; w = 4; ys_correct = [1.0000 1.1089 1.2337 1.3770 1.5420 1.7042 1.8588 2.0339 2.2330 2.4596]; ys = movingAverage(x,y,w); assert(norm(ys_correct-ys)<.001)

3   Pass
x = 0:6; y = sin(x); w = 1; ys_correct = [0 0.5836 0.6306 0.0979 -0.5249 -0.6650 -0.2794]; ys = movingAverage(x,y,w); assert(norm(ys_correct-ys)<.001)

4   Pass
x = 3:11; y = log(x)'; w = 6; ys_correct = [1.0986 1.3648 1.5664 1.7298 1.8677 2.0463 2.1846 2.2992 2.3979]; ys = movingAverage(x,y,w); assert(norm(ys_correct-ys)<.001)