Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1966117

Submitted on 7 Oct 2019 by BING SHAO
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 = [0 1 2 3 4]; assert(isequal(mono_increase(x),true));

tf = logical 1 n = 5 i = 1 tf = logical 1 i = 2 tf = logical 1 i = 3 tf = logical 1 i = 4 tf = logical 1 i = 5

2   Pass
x = [0]; assert(isequal(mono_increase(x),true));

tf = logical 1 n = 1 i = 1

3   Pass
x = [0 0 0 0 0]; assert(isequal(mono_increase(x),false));

tf = logical 1 n = 5 i = 1 tf = logical 0

4   Pass
x = [0 1 2 3 -4]; assert(isequal(mono_increase(x),false));

tf = logical 1 n = 5 i = 1 tf = logical 1 i = 2 tf = logical 1 i = 3 tf = logical 1 i = 4 tf = logical 0

5   Pass
x = [-3 -4 2 3 4]; assert(isequal(mono_increase(x),false));

tf = logical 1 n = 5 i = 1 tf = logical 0

6   Pass
x = 1:.1:10; assert(isequal(mono_increase(x),true));

tf = logical 1 n = 91 i = 1 tf = logical 1 i = 2 tf = logical 1 i = 3 tf = logical 1 i = 4 tf = logical 1 i = 5 tf = logical 1 i = 6 tf = logical 1 i = 7 tf = logical 1 i = 8 tf = logical 1 i = 9 tf = logical 1 i = 10 tf = logical 1 i = 11 tf = logical 1 i = 12 tf = logical 1 i = 13 tf = logical 1 i = 14 tf = logical 1 i = 15 tf = logical 1 i = 16 tf = logical 1 i = 17 tf = logical 1 i = 18 tf = logical 1 i = 19 tf = logical 1 i = 20 tf = logical 1 i = 21 tf = logical 1 i = 22 tf = logical 1 i = 23 tf = logical 1 i = 24 tf = logical 1 i = 25 tf = logical 1 i = 26 tf = logical 1 i = 27 tf = logical 1 i = 28 tf = logical 1 i = 29 tf = logical 1 i = 30 tf = logical 1 i = 31 tf = logical 1 i = 32 tf = logical 1 i = 33 tf = logical 1 i = 34 tf = logical 1 i = 35 tf = logical 1 i = 36 tf = logical 1 i = 37 tf = logical 1 i = 38 tf = logical 1 i = 39 tf = logical 1 i = 40 tf = logical 1 i = 41 tf = logical 1 i = 42 tf = logical 1 i = 43 tf = logical 1 i = 44 tf = logical 1 i = 45 tf = logical 1 i = 46 tf = logical 1 i = 47 tf = logical 1 i = 48 tf = logical 1 i = 49 tf = logical 1 i = 50 tf = logical 1 i = 51 tf = logical 1 i = 52 tf = logical 1 i = 53 tf = logical 1 i = 54 tf = logical 1 i = 55 tf = logical 1 i = 56 tf = logical 1 i = 57 tf = logical 1 i = 58 tf = logical 1 i = 59 tf = logical 1 i = 60 tf = logical 1 i = 61 tf = logical 1 i = 62 tf = logical 1 i = 63 tf = logical 1 i = 64 tf = logical 1 i = 65 tf = logical 1 i = 66 tf = logical 1 i = 67 tf = logical 1 i = 68 tf = logical 1 i = 69 tf = logical 1 i = 70 tf = logical 1 i = 71 tf = logical 1 i = 72 tf = logical 1 i = 73 tf = logical 1 i = 74 tf = logical 1 i = 75 tf = logical 1 i = 76 tf = logical 1 i = 77 tf = logical 1 i = 78 tf = logical 1 i = 79 tf = logical 1 i = 80 tf = logical 1 i = 81 tf = logical 1 i = 82 tf = logical 1 i = 83 tf = logical 1 i = 84 tf = logical 1 i = 85 tf = logical 1 i = 86 tf = logical 1 i = 87 tf = logical 1 i = 88 tf = logical 1 i = 89 tf = logical 1 i = 90 tf = logical 1 i = 91

7   Pass
x = cumsum(rand(1,100)); x(5) = -1; assert(isequal(mono_increase(x),false));

tf = logical 1 n = 100 i = 1 tf = logical 1 i = 2 tf = logical 1 i = 3 tf = logical 1 i = 4 tf = logical 0

8   Pass
x = cumsum(rand(1,50)); assert(isequal(mono_increase(x),true));

tf = logical 1 n = 50 i = 1 tf = logical 1 i = 2 tf = logical 1 i = 3 tf = logical 1 i = 4 tf = logical 1 i = 5 tf = logical 1 i = 6 tf = logical 1 i = 7 tf = logical 1 i = 8 tf = logical 1 i = 9 tf = logical 1 i = 10 tf = logical 1 i = 11 tf = logical 1 i = 12 tf = logical 1 i = 13 tf = logical 1 i = 14 tf = logical 1 i = 15 tf = logical 1 i = 16 tf = logical 1 i = 17 tf = logical 1 i = 18 tf = logical 1 i = 19 tf = logical 1 i = 20 tf = logical 1 i = 21 tf = logical 1 i = 22 tf = logical 1 i = 23 tf = logical 1 i = 24 tf = logical 1 i = 25 tf = logical 1 i = 26 tf = logical 1 i = 27 tf = logical 1 i = 28 tf = logical 1 i = 29 tf = logical 1 i = 30 tf = logical 1 i = 31 tf = logical 1 i = 32 tf = logical 1 i = 33 tf = logical 1 i = 34 tf = logical 1 i = 35 tf = logical 1 i = 36 tf = logical 1 i = 37 tf = logical 1 i = 38 tf = logical 1 i = 39 tf = logical 1 i = 40 tf = logical 1 i = 41 tf = logical 1 i = 42 tf = logical 1 i = 43 tf = logical 1 i = 44 tf = logical 1 i = 45 tf = logical 1 i = 46 tf = logical 1 i = 47 tf = logical 1 i = 48 tf = logical 1 i = 49 tf = logical 1 i = 50