Cody

# Problem 44821. Scalar Matrix Manipulation

Solution 2009301

Submitted on 8 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   Fail
x = eye(2); y_correct = [0 1; 1 0]; assert(isequal(notdiag(x),y_correct))

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 notdiag (line 2) y = ~x*mode(x) Error in Test1 (line 3) assert(isequal(notdiag(x),y_correct))

2   Fail
x = [4 0 0; 0 4 0; 0 0 4]; y_correct = [0 4 4; 4 0 4; 4 4 0]; assert(isequal(notdiag(x),y_correct))

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 notdiag (line 2) y = ~x*mode(x) Error in Test2 (line 3) assert(isequal(notdiag(x),y_correct))

3   Fail
x = [ -6 0 0 0; 0 -6 0 0; 0 0 -6 0; 0 0 0 -6]; y_correct = [0 -6 -6 -6; -6 0 -6 -6; -6 -6 0 -6; -6 -6 -6 0]; assert(isequal(notdiag(x),y_correct))

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 notdiag (line 2) y = ~x*mode(x) Error in Test3 (line 3) assert(isequal(notdiag(x),y_correct))

4   Fail
x = [100 0 0; 0 100 0; 0 0 100]; y_correct = [0 100 100; 100 0 100; 100 100 0]; assert(isequal(notdiag(x),y_correct))

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 notdiag (line 2) y = ~x*mode(x) Error in Test4 (line 3) assert(isequal(notdiag(x),y_correct))