Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 2867384

Submitted on 22 Aug 2020 by Niraj Velankar
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));

sort_x = 0 1 2 3 4

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

sort_x = -4 0 1 2 3

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

sort_x = -4 -3 2 3 4

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

sort_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 91 9.5000 9.6000 9.7000 9.8000 9.9000 10.0000

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

sort_x = Columns 1 through 17 -1.0000 0.6190 1.4325 1.7384 1.7832 2.5461 3.3013 3.7122 4.0179 4.5550 5.2770 6.1270 6.9442 7.1975 8.1529 9.1315 9.5451 Columns 18 through 34 9.5940 9.8772 9.9480 10.1707 10.3930 10.8343 11.3057 12.0697 12.5039 12.7381 12.7894 13.5034 14.0459 14.4914 14.8709 15.3424 16.1436 Columns 35 through 51 16.8028 17.3445 17.3809 18.1221 18.5707 19.4599 19.9403 20.6738 21.4741 22.4089 22.8213 23.1386 24.1313 24.3580 24.9267 25.1930 25.5822 Columns 52 through 68 26.5122 26.5828 26.6189 26.7032 27.3536 28.1050 29.0809 29.2927 30.0124 30.6097 30.7704 31.1836 31.5571 32.5264 32.7740 33.1906 33.5312 Columns 69 through 85 34.1093 34.2738 34.3393 35.1058 35.2945 35.3326 35.5188 36.3591 36.7710 37.5329 37.9816 38.4431 39.1410 40.0925 40.6961 40.9141 41.2664 Columns 86 through 100 42.0050 42.7176 42.7530 43.2078 43.5997 43.9243 44.1127 44.9315 45.0787 45.8485 46.2295 46.5578 47.0235 47.4815 48.1214

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

sort_x = Columns 1 through 17 0.6037 1.0272 1.9372 2.9023 3.1747 3.9204 4.5951 5.5013 5.7365 6.6836 7.1857 7.6892 7.9367 7.9685 8.5823 9.5579 10.2417 Columns 18 through 34 10.9836 11.7875 12.5796 13.5262 13.6639 14.5856 14.6225 14.7253 15.4302 16.1908 16.8404 16.8821 17.2759 17.3043 17.9066 18.6538 19.0022 Columns 35 through 50 19.3528 19.5395 19.5596 19.7636 20.1350 20.4609 21.3327 21.4417 22.1337 22.7052 23.3654 23.7815 24.1021 24.4079 24.4475 24.4541

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!