Cody

# Problem 2235. Back to basics - mean of corner elements of a matrix

Solution 414244

Submitted on 6 Mar 2014 by Zikobrelli
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 2 3; 4 5 6; 7 8 9] y_correct = 5; assert(isequal(MeanCorner(x),y_correct))

x = 1 2 3 4 5 6 7 8 9 ans = 1.0000 1.0000 1.0000 2.5000 2.5000 2.5000 4.0000 4.0000 4.0000 ans = 5

2   Pass
%% x = magic(4) y_correct = 8.5; assert(isequal(MeanCorner(x),y_correct))

x = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1 ans = 7.2500 1.2500 1.2500 7.2500 3.2500 5.2500 5.2500 3.2500 5.2500 3.2500 3.2500 5.2500 1.2500 7.2500 7.2500 1.2500 ans = 8.5000

3   Pass
%% x = eye(4) y_correct = 0.5; assert(isequal(MeanCorner(x),y_correct))

x = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ans = 0.2500 0 0 0.2500 0 0.2500 0.2500 0 0 0.2500 0.2500 0 0.2500 0 0 0.2500 ans = 0.5000

4   Pass
%% x = repmat(5, 4,4); y_correct = 5; assert(isequal(MeanCorner(x),y_correct))

ans = 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 ans = 5

5   Pass
%% x = [1:10]; y_correct = 5.5; assert(isequal(MeanCorner(x),y_correct))

ans = Columns 1 through 9 2.7500 2.7500 2.7500 2.7500 2.7500 2.7500 2.7500 2.7500 2.7500 Column 10 2.7500 ans = 5.5000