Cody

# Problem 43689. Make an identity matrix whose diagonal elements are 1:n

Solution 1064151

Submitted on 28 Nov 2016 by Junseok Yang
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
x = 1; y_correct = 1; assert(isequal(special_eye(x),y_correct))

a = 0 a = 1 y = 1

2   Pass
x = 3; y_correct = [1 0 0;0 2 0;0 0 3] assert(isequal(special_eye(x),y_correct))

y_correct = 1 0 0 0 2 0 0 0 3 a = 0 0 0 0 0 0 0 0 0 a = 1 0 0 0 0 0 0 0 0 a = 1 0 0 0 2 0 0 0 0 a = 1 0 0 0 2 0 0 0 3 y = 1 0 0 0 2 0 0 0 3

3   Pass
x = 5; y_correct = [1 0 0 0 0;0 2 0 0 0;0 0 3 0 0; 0 0 0 4 0; 0 0 0 0 5] assert(isequal(special_eye(x),y_correct))

y_correct = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 a = 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 a = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a = 1 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 a = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 a = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 0 a = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 y = 1 0 0 0 0 0 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5