Cody

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

Solution 1642016

Submitted on 11 Oct 2018 by Jiahang Li
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)))

q = Inf 10 8 9 9 9 Inf 8 6 4 4 9 Inf 5 7 1 9 1 Inf 1 5 8 8 10 Inf q = 9 4 1 5 10 9 9 8 8 8 1 8 9 6 5 10 9 4 7 1 ans = 9 4 1 5 10 9 9 8 8 8 1 8 9 6 5 10 9 4 7 1 y = 9 4 1 5 10 9 9 8 8 8 1 8 9 6 5 10 9 4 7 1

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))

q = NaN 12 3 17 1 Inf 0 89 2 5 NaN 6 3 62 9 Inf q = NaN 1 2 3 12 5 62 3 0 NaN 9 17 89 6 ans = 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))

q = Inf 1 1 1 1 1 1 Inf 1 1 1 1 1 1 Inf 1 1 1 1 1 1 Inf 1 1 1 1 1 1 Inf 1 1 1 1 1 1 Inf q = Columns 1 through 29 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 Column 30 1 ans = Columns 1 through 29 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 Column 30 1