Cody

# Problem 44449. Moving Median Absolute Deviation

Solution 1503475

Submitted on 24 Apr 2018
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   Fail
v = 1:10; n = 5; stats_correct = [1 1 1 1 1 1]; stats = move_mad(v, n); assert(isequal(stats, stats_correct));

Index exceeds array bounds. Error in move_mad>@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3) (line 4) arrayfun(@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3),1:numel(v)-(n-1)); Error in move_mad (line 4) arrayfun(@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3),1:numel(v)-(n-1)); Error in Test1 (line 4) stats = move_mad(v, n);

2   Fail
v = logspace(0, 1, 10); n = 3; stats_correct = [0.292 0.377 0.486 0.628 0.811 1.048 1.353 1.748]; stats = move_mad(v, n); assert(isequal(stats, stats_correct));

Index exceeds array bounds. Error in move_mad>@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3) (line 4) arrayfun(@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3),1:numel(v)-(n-1)); Error in move_mad (line 4) arrayfun(@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3),1:numel(v)-(n-1)); Error in Test2 (line 4) stats = move_mad(v, n);

3   Fail
rng('default'); v = randn(1000, 1); n = 990; stats_correct = 0.660*ones(1, 11); stats = move_mad(v, n); assert(isequal(stats, stats_correct));

Index exceeds array bounds. Error in move_mad>@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3) (line 4) arrayfun(@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3),1:numel(v)-(n-1)); Error in move_mad (line 4) arrayfun(@(i)round(median(abs(v(i:i+n)-median(v(i:i+n)))),3),1:numel(v)-(n-1)); Error in Test3 (line 5) stats = move_mad(v, n);

### Community Treasure Hunt

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

Start Hunting!