Cody

# Problem 413. Back to basics 23 - Triangular matrix

Solution 1369587

Submitted on 5 Dec 2017 by Luciano Pavesi
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 = ones(4,4); y_correct = [1 0 0 0; 1 1 0 0; 1 1 1 0; 1 1 1 1]; assert(isequal(triangle(x),y_correct))

x = 1 1 1 1 0 1 1 1 0 0 1 1 0 0 0 1 x = 1 1 1 1 1 1 1 0 1 1 0 0 1 0 0 0

2   Pass
x = ones(5,5); y_correct = [1 0 0 0 0; 1 1 0 0 0; 1 1 1 0 0; 1 1 1 1 0; 1 1 1 1 1]; assert(isequal(triangle(x),y_correct))

x = 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 x = 1 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0

3   Pass
x = reshape(1:16,[4,4]); y_correct = [1 2 3 4; 0 6 7 8; 0 0 11 12; 0 0 0 16]'; assert(isequal(triangle(x),y_correct))

x = 1 2 3 4 0 6 7 8 0 0 11 12 0 0 0 16 x = 4 3 2 1 8 7 6 0 12 11 0 0 16 0 0 0

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

x = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 x = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

### Community Treasure Hunt

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

Start Hunting!