Cody

# Problem 44639. Calculate mean value of any pair in a vector.

Solution 2037735

Submitted on 28 Nov 2019 by Asif Newaz
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 = [1, 5, 6, 8, 9, 15]; y_correct = [3, 5.5, 7, 8.5, 12] ; assert(isequal(pair_mean(x),y_correct))

y = 3 y = 3.0000 5.5000 y = 3.0000 5.5000 7.0000 y = 3.0000 5.5000 7.0000 8.5000 y = 3.0000 5.5000 7.0000 8.5000 12.0000

2   Pass
x = [4 5 21 6 2 1 6 63]; y_correct = [4.5, 13, 13.5, 4, 1.5, 3.5, 34.5] ; assert(isequal(pair_mean(x),y_correct))

y = 4.5000 y = 4.5000 13.0000 y = 4.5000 13.0000 13.5000 y = 4.5000 13.0000 13.5000 4.0000 y = 4.5000 13.0000 13.5000 4.0000 1.5000 y = 4.5000 13.0000 13.5000 4.0000 1.5000 3.5000 y = 4.5000 13.0000 13.5000 4.0000 1.5000 3.5000 34.5000

3   Pass
x = [1 1 1 0 0 1 0 1]; y_correct = [1.0000 1.0000 0.5000 0 0.5000 0.5000 0.5000] ; assert(isequal(pair_mean(x),y_correct))

y = 1 y = 1 1 y = 1.0000 1.0000 0.5000 y = 1.0000 1.0000 0.5000 0 y = 1.0000 1.0000 0.5000 0 0.5000 y = 1.0000 1.0000 0.5000 0 0.5000 0.5000 y = 1.0000 1.0000 0.5000 0 0.5000 0.5000 0.5000

4   Pass
x = [1 100 1000 10000]; y_correct = [0.0505 0.5500 5.5000] *1000; assert(isequal(pair_mean(x),y_correct))

y = 50.5000 y = 50.5000 550.0000 y = 1.0e+03 * 0.0505 0.5500 5.5000