Cody

# Problem 42691. Matrix of almost all zeros, except for main diagonal

Solution 1100684

Submitted on 9 Jan 2017 by Daniel Pereira
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 = 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(mat(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

2   Pass
x = 10; y_correct = [1 0 0 0 0 0 0 0 0 0; 0 2 0 0 0 0 0 0 0 0; 0 0 3 0 0 0 0 0 0 0; 0 0 0 4 0 0 0 0 0 0; 0 0 0 0 5 0 0 0 0 0; 0 0 0 0 0 6 0 0 0 0; 0 0 0 0 0 0 7 0 0 0; 0 0 0 0 0 0 0 8 0 0; 0 0 0 0 0 0 0 0 9 0; 0 0 0 0 0 0 0 0 0 10] assert(isequal(mat(x),y_correct))

y_correct = 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 10

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!