Cody

Solution 1911278

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

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

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

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 ans = 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

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 39 25 14 53 44 87 78 12 3 52 33 68 92 11 15 43 65 95 85 69 30 30 3 5 90 48 46 83 86 80 Columns 31 through 60 83 55 60 48 73 84 36 65 31 96 54 91 55 65 48 26 51 12 78 46 86 54 52 75 68 33 32 79 54 9 Columns 61 through 90 32 6 93 29 61 11 91 62 46 80 2 76 53 100 52 12 72 1 92 36 92 66 100 34 76 64 92 68 22 2 Columns 91 through 104 48 99 21 50 96 39 7 98 48 19 4 94 76 74 ans = Columns 1 through 30 39 25 14 53 44 87 78 12 3 52 33 68 92 11 15 43 65 95 85 69 30 30 3 5 90 48 46 83 86 80 Columns 31 through 60 83 55 60 48 73 84 36 65 31 96 54 91 55 65 48 26 51 12 78 46 86 54 52 75 68 33 32 79 54 9 Columns 61 through 90 32 6 93 29 61 11 91 62 46 80 2 76 53 100 52 12 72 1 92 36 92 66 100 34 76 64 92 68 22 2 Columns 91 through 104 48 99 21 50 96 39 7 98 48 19 4 94 76 74

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