Cody

Solution 1911280

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 1 2 3 0 0 0 0 ans = 0 0 0 0 0 1 2 3 0 ans = 2 3 0 0 0 0 0 0 1

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 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 3 -2 0 0 0 0 0 ans = 0 0 0 3 -2 0 0 0 ans = 0 0 0 0 0 3 -2 0 ans = -2 0 0 0 0 0 0 3

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

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 19 44 17 83 71 96 75 6 81 52 26 12 55 33 55 41 93 42 29 80 7 63 70 2 63 85 84 16 37 32 Columns 31 through 60 84 75 56 72 47 87 10 80 52 47 45 92 11 61 49 82 26 33 97 88 56 83 75 81 8 56 38 54 97 97 Columns 61 through 90 1 13 95 32 70 11 100 18 15 27 20 81 36 39 19 48 74 21 98 55 18 35 36 55 89 64 78 53 75 47 Columns 91 through 104 78 67 44 70 59 22 78 30 65 58 79 39 45 76 ans = Columns 1 through 30 44 17 83 71 96 75 6 81 52 26 12 55 33 55 41 93 42 29 80 7 63 70 2 63 85 84 16 37 32 84 Columns 31 through 60 75 56 72 47 87 10 80 52 47 45 92 11 61 49 82 26 33 97 88 56 83 75 81 8 56 38 54 97 97 1 Columns 61 through 90 13 95 32 70 11 100 18 15 27 20 81 36 39 19 48 74 21 98 55 18 35 36 55 89 64 78 53 75 47 78 Columns 91 through 104 67 44 70 59 22 78 30 65 58 79 39 45 76 19

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