Cody

# Problem 44080. Construct a "diagAdiag" matrix

Solution 1681090

Submitted on 27 Nov 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 = 3; y_correct = [1 2 6; 3 5 7;4 8 9]; assert(isequal(diagAdiag(x),y_correct))

le = 1 le = 2 le = 3 le = 2 le = 1 y = 1 2 6 3 5 7 4 8 9

2   Pass
x = 4; y_correct = [1 2 6 7; 3 5 8 13;4 9 12 14;10 11 15 16]; assert(isequal(diagAdiag(x),y_correct))

le = 1 le = 2 le = 3 le = 4 le = 3 le = 2 le = 1 y = 1 2 6 7 3 5 8 13 4 9 12 14 10 11 15 16

3   Pass
x = 5; y_correct = [1 2 6 7 15;3 5 8 14 16;4 9 13 17 22;10 12 18 21 23;11 19 20 24 25]; assert(isequal(diagAdiag(x),y_correct))

le = 1 le = 2 le = 3 le = 4 le = 5 le = 4 le = 3 le = 2 le = 1 y = 1 2 6 7 15 3 5 8 14 16 4 9 13 17 22 10 12 18 21 23 11 19 20 24 25

4   Pass
x = 6; y_correct = [ 1 2 6 7 15 16; 3 5 8 14 17 26; 4 9 13 18 25 27; 10 12 19 24 28 33; 11 20 23 29 32 34; 21 22 30 31 35 36]; assert(isequal(diagAdiag(x),y_correct))

le = 1 le = 2 le = 3 le = 4 le = 5 le = 6 le = 5 le = 4 le = 3 le = 2 le = 1 y = 1 2 6 7 15 16 3 5 8 14 17 26 4 9 13 18 25 27 10 12 19 24 28 33 11 20 23 29 32 34 21 22 30 31 35 36

5   Pass
x = 7; y_correct = [ 1 2 6 7 15 16 28; 3 5 8 14 17 27 29; 4 9 13 18 26 30 39; 10 12 19 25 31 38 40; 11 20 24 32 37 41 46; 21 23 33 36 42 45 47; 22 34 35 43 44 48 49]; assert(isequal(diagAdiag(x),y_correct))

le = 1 le = 2 le = 3 le = 4 le = 5 le = 6 le = 7 le = 6 le = 5 le = 4 le = 3 le = 2 le = 1 y = 1 2 6 7 15 16 28 3 5 8 14 17 27 29 4 9 13 18 26 30 39 10 12 19 25 31 38 40 11 20 24 32 37 41 46 21 23 33 36 42 45 47 22 34 35 43 44 48 49