Cody

# Problem 44739. Return all matrix elements except elements on diagonal

Solution 1662481

Submitted on 30 Oct 2018 by Martin C.
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 = randi(10,5,5); y=elmex(x) assert(isequal(y(1),x(6)))

y = NaN 3 4 3 7 3 NaN 6 8 2 6 1 NaN 2 9 9 7 8 NaN 10 9 8 7 5 NaN y = NaN 3 6 9 9 3 NaN 1 7 8 4 6 NaN 8 7 3 8 2 NaN 5 7 2 9 10 NaN y = 3 6 9 9 3 1 7 8 4 6 8 7 3 8 2 5 7 2 9 10 y = 3 6 9 9 3 1 7 8 4 6 8 7 3 8 2 5 7 2 9 10

2   Pass
x = [0 1 2 3;12 15 5 62;3 0 0 9;17 89 6 1]; y_correct = [1 2 3 12 5 62 3 0 9 17 89 6]; assert(isequal(elmex(x),y_correct))

y = NaN 12 3 17 1 NaN 0 89 2 5 NaN 6 3 62 9 NaN y = NaN 1 2 3 12 NaN 5 62 3 0 NaN 9 17 89 6 NaN y = 1 2 3 12 5 62 3 0 9 17 89 6

3   Pass
x = ones(6,6); y_correct = ones(1,30); assert(isequal(elmex(x),y_correct))

y = NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN y = NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN 1 1 1 1 1 1 NaN y = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1