Cody

Problem 43481. Modified Upper Matrix Mock

Solution 2907694

Submitted on 3 Sep 2020 by Ramesh Kumar V
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 3 6 9 11]; y_correct = [1 3 6 9 11; 0 3 6 9 11; 0 0 6 9 11; 0 0 0 9 11; 0 0 0 0 11] assert(isequal(upMat(x),y_correct))

y_correct = 1 3 6 9 11 0 3 6 9 11 0 0 6 9 11 0 0 0 9 11 0 0 0 0 11 m = 5 y = [] y = 1 3 6 9 11 x = 0 3 6 9 11 y = 1 3 6 9 11 0 3 6 9 11 x = 0 0 6 9 11 y = 1 3 6 9 11 0 3 6 9 11 0 0 6 9 11 x = 0 0 0 9 11 y = 1 3 6 9 11 0 3 6 9 11 0 0 6 9 11 0 0 0 9 11 x = 0 0 0 0 11 y = 1 3 6 9 11 0 3 6 9 11 0 0 6 9 11 0 0 0 9 11 0 0 0 0 11 x = 0 0 0 0 0

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

y_correct = 1 2 3 4 5 0 2 3 4 5 0 0 3 4 5 0 0 0 4 5 0 0 0 0 5 m = 5 y = [] y = 1 2 3 4 5 x = 0 2 3 4 5 y = 1 2 3 4 5 0 2 3 4 5 x = 0 0 3 4 5 y = 1 2 3 4 5 0 2 3 4 5 0 0 3 4 5 x = 0 0 0 4 5 y = 1 2 3 4 5 0 2 3 4 5 0 0 3 4 5 0 0 0 4 5 x = 0 0 0 0 5 y = 1 2 3 4 5 0 2 3 4 5 0 0 3 4 5 0 0 0 4 5 0 0 0 0 5 x = 0 0 0 0 0

3   Pass
x = [10 9 8]; y_correct = [10 9 8; 0 9 8; 0 0 8] assert(isequal(upMat(x),y_correct))

y_correct = 10 9 8 0 9 8 0 0 8 m = 3 y = [] y = 10 9 8 x = 0 9 8 y = 10 9 8 0 9 8 x = 0 0 8 y = 10 9 8 0 9 8 0 0 8 x = 0 0 0

Suggested Problems

More from this Author43

Community Treasure Hunt

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

Start Hunting!