Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1631025

Submitted on 20 Sep 2018 by Bob Tivnan
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));

xs = 0 1 2 3 4 xsu = 0 1 2 3 4 tf = 1

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

xs = 0 xsu = 0 tf = 1

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

xs = 0 0 0 0 0 xsu = 0 tf = 0

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

xs = -4 0 1 2 3 xsu = -4 0 1 2 3 tf = 0

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

xs = -4 -3 2 3 4 xsu = -4 -3 2 3 4 tf = 0

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

xs = Columns 1 through 18 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 2.7000 Columns 19 through 36 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 4.4000 4.5000 Columns 37 through 54 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 6.1000 6.2000 6.3000 Columns 55 through 72 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 7.8000 7.9000 8.0000 8.1000 Columns 73 through 90 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 9.5000 9.6000 9.7000 9.8000 9.9000 Column 91 10.0000 xsu = Columns 1 through 18 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 2.7000 Columns 19 through 36 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 4.4000 4.5000 Columns 37 through 54 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 6.1000 6.2000 6.3000 Columns 55 through 72 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 7.8000 7.9000 8.0000 8.1000 Columns 73 through 90 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 9.5000 9.6000 9.7000 9.8000 9.9000 Column 91 10.0000 tf = 1

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

xs = Columns 1 through 18 -1.0000 0.4669 1.2044 1.7488 2.4675 2.9713 3.2059 3.9030 3.9218 4.6787 5.3192 5.5568 5.6726 6.4668 6.8667 6.9512 7.9023 8.8036 Columns 19 through 36 8.8938 9.0532 9.5531 10.4809 11.4754 12.1172 12.8969 13.8559 14.2348 15.2342 16.0218 16.6576 17.0962 17.4310 17.8027 18.1440 18.1638 18.7661 Columns 37 through 54 19.0042 19.6898 20.1903 20.4716 20.9175 21.0878 21.6382 22.4899 23.0609 23.4773 23.7747 23.9542 24.8770 25.1301 25.9975 26.1236 26.5882 26.7886 Columns 55 through 72 27.3239 28.0561 28.8184 29.7150 30.2013 31.0459 31.1543 31.6462 32.4417 32.8294 33.0711 33.5315 34.5157 34.8133 35.6487 36.3274 36.6832 37.6409 Columns 73 through 90 38.0744 38.4593 38.8794 39.4303 40.2812 40.7030 41.3583 41.9267 42.6672 43.3809 43.4497 44.4496 44.6957 44.8514 45.5373 46.5343 47.1239 47.6034 Columns 91 through 100 48.4999 49.1314 49.5891 49.8790 50.2404 50.8357 50.9344 51.5612 52.0039 52.1843 xsu = Columns 1 through 18 -1.0000 0.4669 1.2044 1.7488 2.4675 2.9713 3.2059 3.9030 3.9218 4.6787 5.3192 5.5568 5.6726 6.4668 6.8667 6.9512 7.9023 8.8036 Columns 19 through 36 8.8938 9.0532 9.5531 10.4809 11.4754 12.1172 12.8969 13.8559 14.2348 15.2342 16.0218 16.6576 17.0962 17.4310 17.8027 18.1440 18.1638 18.7661 Columns 37 through 54 19.0042 19.6898 20.1903 20.4716 20.9175 21.0878 21.6382 22.4899 23.0609 23.4773 23.7747 23.9542 24.8770 25.1301 25.9975 26.1236 26.5882 26.7886 Columns 55 through 72 27.3239 28.0561 28.8184 29.7150 30.2013 31.0459 31.1543 31.6462 32.4417 32.8294 33.0711 33.5315 34.5157 34.8133 35.6487 36.3274 36.6832 37.6409 Columns 73 through 90 38.0744 38.4593 38.8794 39.4303 40.2812 40.7030 41.3583 41.9267 42.6672 43.3809 43.4497 44.4496 44.6957 44.8514 45.5373 46.5343 47.1239 47.6034 Columns 91 through 100 48.4999 49.1314 49.5891 49.8790 50.2404 50.8357 50.9344 51.5612 52.0039 52.1843 tf = 0

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

xs = Columns 1 through 18 0.2089 0.9654 1.4316 1.7858 1.8821 2.6215 3.3668 3.5232 3.5696 3.9073 4.2357 4.7871 5.1553 6.0898 6.1935 7.1840 7.2830 7.5756 Columns 19 through 36 8.5369 8.5728 9.5564 9.6429 10.4265 11.4101 11.6041 11.7819 12.4188 13.2307 13.8480 14.5530 14.9418 15.3224 15.5741 16.1365 16.6526 17.5963 Columns 37 through 50 18.5589 18.7023 18.9158 19.6727 20.1310 20.1465 20.5681 20.7854 21.7428 22.4553 22.6142 23.2597 23.9991 24.5437 xsu = Columns 1 through 18 0.2089 0.9654 1.4316 1.7858 1.8821 2.6215 3.3668 3.5232 3.5696 3.9073 4.2357 4.7871 5.1553 6.0898 6.1935 7.1840 7.2830 7.5756 Columns 19 through 36 8.5369 8.5728 9.5564 9.6429 10.4265 11.4101 11.6041 11.7819 12.4188 13.2307 13.8480 14.5530 14.9418 15.3224 15.5741 16.1365 16.6526 17.5963 Columns 37 through 50 18.5589 18.7023 18.9158 19.6727 20.1310 20.1465 20.5681 20.7854 21.7428 22.4553 22.6142 23.2597 23.9991 24.5437 tf = 1

### Community Treasure Hunt

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

Start Hunting!