Cody

Solution 1911281

Submitted on 24 Aug 2019
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   Fail
a = [1 2 3]; n = 3; A_correct = [1 2 3 0 0 0 0 0 0; 0 0 0 1 2 3 0 0 0; 0 0 0 0 0 0 1 2 3]; assert(isequal(block_diagonal(a,n),A_correct))

c = 1 2 3 0 0 0 0 0 0 ans = 0 0 0 1 2 3 0 0 0 ans = 0 0 0 0 0 0 1 2 3

Output argument "A" (and maybe others) not assigned during call to "block_diagonal". Error in Test1 (line 4) assert(isequal(block_diagonal(a,n),A_correct))

2   Fail
a = []; n = 3; A_correct = []; assert(isequal(block_diagonal(a,n),A_correct))

c = 1×0 empty double row vector ans = 1×0 empty double row vector ans = 1×0 empty double row vector

Output argument "A" (and maybe others) not assigned during call to "block_diagonal". Error in Test2 (line 4) assert(isequal(block_diagonal(a,n),A_correct))

3   Fail
a = [1 2 -3]'; n = 0; A_correct = []; assert(isequal(block_diagonal(a,n),A_correct))

c = 1 2 -3

Output argument "A" (and maybe others) not assigned during call to "block_diagonal". Error in Test3 (line 4) assert(isequal(block_diagonal(a,n),A_correct))

4   Fail
a = [3 -2]'; n = 4; A_correct = [3 -2 0 0 0 0 0 0; 0 0 3 -2 0 0 0 0; 0 0 0 0 3 -2 0 0; 0 0 0 0 0 0 3 -2]'; assert(isequal(block_diagonal(a,n),A_correct))

c = 3 -2 0 0 0 0 0 0 ans = 0 0 3 -2 0 0 0 0 ans = 0 0 0 0 3 -2 0 0 ans = 0 0 0 0 0 0 3 -2

Output argument "A" (and maybe others) not assigned during call to "block_diagonal". Error in Test4 (line 4) assert(isequal(block_diagonal(a,n),A_correct))

5   Fail
a = 6; n = 23; A_correct = a*eye(n); assert(isequal(block_diagonal(a,n),A_correct))

c = 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 0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 0 0 0 0 0 0 0 0 0 6

Output argument "A" (and maybe others) not assigned during call to "block_diagonal". Error in Test5 (line 4) assert(isequal(block_diagonal(a,n),A_correct))

6   Fail
a = magic(5); n = 2; A_correct = [a zeros(5); zeros(5) a]; assert(isequal(block_diagonal(a,n),A_correct))

c = Columns 1 through 30 17 23 4 10 11 24 5 6 12 18 1 7 13 19 25 8 14 20 21 2 15 16 22 3 9 0 0 0 0 0 Columns 31 through 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = Columns 1 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 23 4 10 11 Columns 31 through 50 24 5 6 12 18 1 7 13 19 25 8 14 20 21 2 15 16 22 3 9

Output argument "A" (and maybe others) not assigned during call to "block_diagonal". Error in Test6 (line 4) assert(isequal(block_diagonal(a,n),A_correct))

7   Fail
a = randi(100,13,8); n = 1; A_correct = a; assert(isequal(block_diagonal(a,n),A_correct))

c = Columns 1 through 30 40 50 66 28 48 21 8 8 91 31 25 32 70 75 53 21 93 25 13 70 48 42 78 72 78 49 62 8 84 14 Columns 31 through 60 62 40 54 36 29 55 71 78 82 63 25 4 90 10 83 68 9 24 24 16 38 5 40 90 33 84 33 95 46 69 Columns 61 through 90 16 56 35 35 48 61 2 69 65 38 18 18 59 18 13 41 69 92 18 18 56 73 81 34 67 8 17 76 89 75 Columns 91 through 104 61 70 68 68 46 100 100 88 23 60 68 49 72 9

Output argument "A" (and maybe others) not assigned during call to "block_diagonal". Error in Test7 (line 4) assert(isequal(block_diagonal(a,n),A_correct))

Suggested Problems

More from this Author1