Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 2946976

Submitted on 14 Sep 2020 by Levente Dáms
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));

tmp = 1 2 3 4 5 tf = logical 1

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

tmp = 1 2 3 -4 -3 tf = logical 0

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

tmp = -4 2 3 4 5 tf = logical 0

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

tmp = Columns 1 through 18 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 2.8000 Columns 19 through 36 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 4.6000 Columns 37 through 54 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 6.4000 Columns 55 through 72 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 8.2000 Columns 73 through 90 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 10.0000 Column 91 11.0000 tf = logical 1

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

tmp = Columns 1 through 18 1.0340 1.7160 2.6990 -1.0000 3.5262 3.6279 4.0366 4.2783 4.5377 5.1486 5.3762 5.9318 6.1669 6.6143 7.5277 8.4595 8.5291 9.0553 Columns 19 through 36 9.0976 9.6326 10.5131 11.1004 11.2948 11.7179 11.8122 12.3624 12.5216 13.1525 13.6344 13.9554 13.9877 14.7535 15.0979 15.1320 15.9705 16.8352 Columns 37 through 54 17.4873 17.8262 18.5282 19.4332 20.3689 21.0786 21.8818 22.3924 23.0432 23.8604 24.5636 25.5040 25.5064 26.2517 27.2397 27.4894 28.2662 29.1611 Columns 55 through 72 30.1271 30.4641 30.5833 30.9495 31.6046 32.2359 32.5345 33.2829 33.5504 34.2002 34.8253 35.4611 36.0033 36.5108 37.2005 37.6145 37.7619 37.9052 Columns 73 through 90 38.8537 39.7744 40.3001 41.0373 41.8592 42.2019 42.6228 43.5334 44.3359 45.3090 46.0317 46.7029 47.6233 48.5169 48.6632 49.0511 49.8679 49.9571 Columns 91 through 100 50.2615 50.6605 51.6369 51.9133 52.6151 52.8492 53.1633 53.4600 54.1560 55.1560 tf = logical 0

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

tmp = Columns 1 through 18 1.6686 2.5318 3.1575 3.9075 4.6356 4.9391 5.4763 6.0223 6.1639 7.0754 7.1272 7.6649 8.1497 8.6795 9.1295 9.5775 10.1398 10.7776 Columns 19 through 36 11.2614 11.2695 12.1719 12.5499 13.2021 13.3724 13.4663 14.0208 14.6653 15.0105 15.5317 16.4610 16.6044 17.3198 17.4097 17.8404 18.5398 19.0422 Columns 37 through 50 19.8836 20.7819 21.5595 21.9183 21.9714 22.5980 23.2523 23.3811 24.3179 24.5157 24.5615 25.2611 25.8154 26.8154 tf = logical 1

### Community Treasure Hunt

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

Start Hunting!