Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 2760445

Submitted on 30 Jul 2020 by Yuna Liu
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));

tf = logical 1 V = 1 V = 2 V = 3 V = 4

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

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

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

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

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

tf = logical 1 V = 1.1000 V = 1.2000 V = 1.3000 V = 1.4000 V = 1.5000 V = 1.6000 V = 1.7000 V = 1.8000 V = 1.9000 V = 2 V = 2.1000 V = 2.2000 V = 2.3000 V = 2.4000 V = 2.5000 V = 2.6000 V = 2.7000 V = 2.8000 V = 2.9000 V = 3 V = 3.1000 V = 3.2000 V = 3.3000 V = 3.4000 V = 3.5000 V = 3.6000 V = 3.7000 V = 3.8000 V = 3.9000 V = 4 V = 4.1000 V = 4.2000 V = 4.3000 V = 4.4000 V = 4.5000 V = 4.6000 V = 4.7000 V = 4.8000 V = 4.9000 V = 5 V = 5.1000 V = 5.2000 V = 5.3000 V = 5.4000 V = 5.5000 V = 5.6000 V = 5.7000 V = 5.8000 V = 5.9000 V = 6 V = 6.1000 V = 6.2000 V = 6.3000 V = 6.4000 V = 6.5000 V = 6.6000 V = 6.7000 V = 6.8000 V = 6.9000 V = 7 V = 7.1000 V = 7.2000 V = 7.3000 V = 7.4000 V = 7.5000 V = 7.6000 V = 7.7000 V = 7.8000 V = 7.9000 V = 8 V = 8.1000 V = 8.2000 V = 8.3000 V = 8.4000 V = 8.5000 V = 8.6000 V = 8.7000 V = 8.8000 V = 8.9000 V = 9 V = 9.1000 V = 9.2000 V = 9.3000 V = 9.4000 V = 9.5000 V = 9.6000 V = 9.7000 V = 9.8000 V = 9.9000 V = 10

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

tf = logical 1 V = 1.0083 V = 1.0517 V = 1.4523 V = -1 tf = logical 0 V = 2.8364 V = 3.1349 V = 3.6950 V = 3.9303 V = 4.4173 V = 5.3858 V = 5.9178 V = 6.2576 V = 6.5001 V = 6.9254 V = 7.7315 V = 8.3424 V = 8.4019 V = 8.5104 V = 8.5751 V = 8.6327 V = 9.2790 V = 9.4803 V = 10.1945 V = 10.3510 V = 11.0352 V = 11.0690 V = 11.1131 V = 11.2674 V = 11.2916 V = 11.3062 V = 11.9618 V = 12.9265 V = 13.8764 V = 14.0889 V = 14.8273 V = 15.0354 V = 15.3062 V = 15.8393 V = 16.0271 V = 16.6266 V = 16.9149 V = 17.1920 V = 17.2558 V = 18.0631 V = 18.5793 V = 19.5292 V = 20.3283 V = 20.7953 V = 21.4141 V = 21.4531 V = 22.2614 V = 23.2044 V = 23.9613 V = 24.8050 V = 25.0268 V = 25.8647 V = 26.7520 V = 27.5185 V = 28.3452 V = 28.6487 V = 29.0537 V = 29.6574 V = 29.8427 V = 30.7052 V = 31.1339 V = 31.3127 V = 31.6644 V = 32.1820 V = 32.1925 V = 32.9438 V = 33.7384 V = 34.2273 V = 34.9590 V = 35.3018 V = 35.8643 V = 36.6115 V = 37.2471 V = 37.7862 V = 38.6527 V = 39.5156 V = 39.7129 V = 40.0782 V = 40.9249 V = 41.4497 V = 42.3302 V = 42.8650 V = 43.4542 V = 44.3412 V = 44.3927 V = 44.5931 V = 44.8847 V = 45.3676 V = 45.9055 V = 46.1943 V = 46.3817 V = 46.8622 V = 47.6477 V = 48.1937 V = 48.4686

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

tf = logical 1 V = 0.6690 V = 0.9379 V = 1.0282 V = 1.5243 V = 2.1443 V = 2.6288 V = 2.9719 V = 3.7400 V = 4.0633 V = 4.4452 V = 4.6596 V = 5.2679 V = 5.5219 V = 6.4660 V = 6.6619 V = 6.8635 V = 7.1839 V = 7.3495 V = 7.5551 V = 8.2085 V = 8.4984 V = 9.0319 V = 9.9902 V = 10.4239 V = 10.7251 V = 11.2628 V = 11.6385 V = 11.9742 V = 12.1155 V = 13.0909 V = 14.0258 V = 14.6298 V = 14.9986 V = 15.2940 V = 16.1863 V = 16.7431 V = 17.2655 V = 18.0577 V = 18.4657 V = 19.0985 V = 19.3256 V = 19.9491 V = 20.8291 V = 21.4649 V = 22.0315 V = 22.0744 V = 23.0057 V = 23.0829 V = 23.5529

### Community Treasure Hunt

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

Start Hunting!