Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 1174921

Submitted on 28 Apr 2017 by Limon
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));

s = 0 s = 1 s = 2 s = 3 s = 4 b = 4 a = 4 tf = logical 1

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

s = 0 b = 0 a = 0 tf = logical 1

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

s = 0 b = 0 a = 4 tf = logical 0

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

s = 0 s = 1 s = 2 s = 3 b = 3 a = 4 tf = logical 0

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

s = 0 s = 1 s = 2 s = 3 b = 3 a = 4 tf = logical 0

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

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

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

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

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

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

Community Treasure Hunt

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

Start Hunting!