Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 1993212

Submitted on 28 Oct 2019 by JanaS
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
x = [0 1 2 3 4]; assert(isequal(mono_increase(x),true));

xx = 0 1 2 3 4 pom = logical 1

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

xx = 0 pom = logical 1

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

xx = 0 0 0 0 0 pom = logical 1

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

xx = -4 0 1 2 3 pom = logical 0

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

xx = -4 -3 2 3 4 pom = logical 0

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

xx = 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 91 9.5000 9.6000 9.7000 9.8000 9.9000 10.0000 pom = logical 1

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

xx = Columns 1 through 17 -1.0000 0.7774 1.2032 1.4596 1.9458 3.3913 3.4959 3.9419 4.5550 4.8802 5.7230 5.8115 6.0491 6.4678 7.3407 8.0800 8.5922 Columns 18 through 34 9.1660 9.2670 10.0389 10.8504 11.6041 11.7867 12.7066 13.6420 14.3195 14.9872 15.2768 15.7501 16.6216 17.3815 17.4703 17.8537 18.8104 Columns 35 through 51 19.0234 19.5837 20.5770 21.5756 21.6414 22.5228 23.4478 24.1792 24.2411 24.5138 25.0407 25.0828 25.9707 26.0447 26.3637 27.2085 27.9010 Columns 52 through 68 28.8353 29.5216 30.0632 30.5775 30.6642 30.8396 31.8078 32.1535 32.2026 32.2059 32.3269 32.7097 33.5133 33.6931 34.2215 34.4128 34.4423 Columns 69 through 85 34.7924 35.4347 36.3967 36.7586 36.7969 37.0454 37.7681 38.2252 38.8050 38.9497 39.2032 39.3912 39.4959 40.3682 41.2585 42.1833 42.2793 Columns 86 through 100 42.9366 43.5884 43.6214 44.3563 45.1235 45.3230 45.8637 46.0439 46.4352 47.2670 48.1253 48.2652 48.5476 49.1649 49.3007 pom = logical 0

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

xx = Columns 1 through 17 0.0860 0.4996 1.3563 2.0110 2.7542 3.3634 3.9278 4.8996 5.4850 6.4777 6.5808 6.6619 6.7371 7.6130 7.7899 8.2453 8.6648 Columns 18 through 34 8.9416 9.1830 9.2469 9.8185 10.7921 11.2286 11.7862 12.3796 13.1147 13.1984 14.0720 14.3492 14.6404 14.8911 15.8768 16.0698 16.1247 Columns 35 through 50 16.4006 16.5029 17.2878 17.3112 17.5635 18.0637 18.3543 18.5497 19.0534 19.6037 19.9008 20.3742 21.3523 22.3361 22.8362 23.2671 pom = logical 1

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!