Cody

Solution 2003053

Submitted on 5 Nov 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   Pass
n = 2; y = [1 0;0 1]; assert(isequal(M_Const(n),y))

y = 1 0 0 1

2   Fail
n = 4; y = [1 2 0 0 1 2 0 0; 0 0 2 1 0 0 2 1]; assert(isequal(M_Const(n),y))

Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in M_Const (line 4) A=a*ones(n/2,1); Error in Test2 (line 6) assert(isequal(M_Const(n),y))

3   Fail
n = 6; y = [1 2 3 0 0 0 1 2 3 0 0 0 1 2 3 0 0 0 0 0 0 3 2 1 0 0 0 3 2 1 0 0 0 3 2 1]; assert(isequal(M_Const(n),y))

Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in M_Const (line 4) A=a*ones(n/2,1); Error in Test3 (line 8) assert(isequal(M_Const(n),y))

4   Fail
n = 8; y = [ 1 2 3 4 0 0 0 0 1 2 3 4 0 0 0 0 1 2 3 4 0 0 0 0 1 2 3 4 0 0 0 0 0 0 0 0 4 3 2 1 0 0 0 0 4 3 2 1 0 0 0 0 4 3 2 1 0 0 0 0 4 3 2 1]; assert(isequal(M_Const(n),y))

Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in M_Const (line 4) A=a*ones(n/2,1); Error in Test4 (line 10) assert(isequal(M_Const(n),y))

Suggested Problems

More from this Author21