Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1524011

Submitted on 9 May 2018 by Sandro Flury
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));

x = 0 1 2 3 4 Inf tf = logical 1

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

x = 0 Inf tf = logical 1

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

x = 0 0 0 0 0 Inf tf = logical 0

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

x = 0 1 2 3 -4 Inf tf = logical 0

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

x = -3 -4 2 3 4 Inf tf = logical 0

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

x = Columns 1 through 17 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 Columns 18 through 34 2.7000 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 Columns 35 through 51 4.4000 4.5000 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 Columns 52 through 68 6.1000 6.2000 6.3000 6.4000 6.5000 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000 7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 Columns 69 through 85 7.8000 7.9000 8.0000 8.1000 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000 8.8000 8.9000 9.0000 9.1000 9.2000 9.3000 9.4000 Columns 86 through 92 9.5000 9.6000 9.7000 9.8000 9.9000 10.0000 Inf tf = logical 1

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

x = Columns 1 through 17 0.7327 1.6590 2.4196 3.1964 -1.0000 4.8524 5.0712 5.8222 6.4528 6.4907 7.1665 7.8099 8.5268 8.5575 8.9185 9.5092 10.1913 Columns 18 through 34 10.7230 11.0272 11.6499 12.3458 12.5716 13.1240 13.6361 14.1030 14.5400 14.8170 14.9261 15.3196 16.2950 16.8804 17.6189 18.1344 19.1100 Columns 35 through 51 19.9710 20.3859 20.7410 21.1318 22.1028 22.9426 23.3034 23.3344 23.8067 24.5560 25.3350 26.2227 26.7994 27.7236 28.1542 28.8217 29.5066 Columns 52 through 68 29.5305 29.6553 30.1019 30.8400 31.1056 31.7146 32.5015 33.4864 33.7201 34.4955 35.2040 36.0792 36.4095 37.1348 37.6349 38.5897 38.7454 Columns 69 through 85 39.5828 39.8737 40.5294 41.2005 41.5534 41.8692 42.7239 42.8327 43.2389 43.9108 44.1354 45.0935 45.3126 45.9451 46.6268 47.5815 48.2770 Columns 86 through 101 48.3567 49.2655 49.4545 49.5913 50.0958 51.0198 51.3148 51.8447 52.4374 52.6600 53.3243 54.0139 54.2671 55.1594 55.5093 Inf tf = logical 0

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

x = Columns 1 through 17 0.1885 0.7806 1.3410 1.9740 2.0842 2.1439 3.0800 3.9107 4.3052 4.5459 4.9103 5.6239 6.5125 6.7578 6.8918 7.5761 8.4544 Columns 18 through 34 8.4582 8.5648 9.4405 10.2291 10.9981 11.3787 11.3910 11.5139 11.5586 11.8639 12.3774 12.7442 13.0031 13.0057 13.4265 14.4205 14.7759 Columns 35 through 51 14.7830 14.8257 15.1938 15.9328 16.4180 17.2646 17.9883 18.7601 18.8676 18.9028 19.3199 19.4443 20.2366 20.3491 20.7307 21.3816 Inf tf = logical 1

### Community Treasure Hunt

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

Start Hunting!