Cody

Solution 2458526

Submitted on 2 Jun 2020
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 = [1:4]; y_correct = [1 0 0 0; 0 2 0 0; 0 0 3 0; 0 0 0 4]; assert(isequal(diag_array(x),y_correct))

m = 1 n = 4 a = 0 0 0 0 a = 1 0 0 0

Index in position 1 exceeds array bounds (must not exceed 1). Error in diag_array (line 5) a(i,i)=a(i,i)+x(i) Error in Test1 (line 3) assert(isequal(diag_array(x),y_correct))

2   Fail
x = [100 23 3.14 12 200]; y_correct = [100.0000 0 0 0 0; 0 23.0000 0 0 0; 0 0 3.1400 0 0; 0 0 0 12.0000 0; 0 0 0 0 200.0000] assert(isequal(diag_array(x),y_correct))

y_correct = 100.0000 0 0 0 0 0 23.0000 0 0 0 0 0 3.1400 0 0 0 0 0 12.0000 0 0 0 0 0 200.0000 m = 1 n = 5 a = 0 0 0 0 0 a = 100 0 0 0 0

Index in position 1 exceeds array bounds (must not exceed 1). Error in diag_array (line 5) a(i,i)=a(i,i)+x(i) Error in Test2 (line 7) assert(isequal(diag_array(x),y_correct))

Suggested Problems

More from this Author39