Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1669723

Submitted on 8 Nov 2018 by Sharon Spelt
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));

ic = 0 1 2 3 4 tf = logical 1

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

ic = 0 tf = logical 1

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

ic = 0 tf = 0

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

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

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

ic = -4 -3 2 3 4 tf = logical 0

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

ic = 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 = logical 1

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

ic = Columns 1 through 18 -1.0000 0.5024 1.2661 1.4018 2.2767 2.7097 3.5567 3.7503 4.3564 4.5171 5.0073 5.6009 6.4466 6.7570 7.7389 7.8240 8.1846 9.1203 Columns 19 through 36 9.6782 10.0118 10.8550 11.5983 11.9005 12.3443 12.4626 13.2264 13.4135 14.3932 15.3515 15.6925 15.8086 15.9389 16.2676 16.4759 16.9176 17.6895 Columns 37 through 54 18.5360 19.1085 19.6881 20.0119 20.9081 21.3573 22.0994 22.6657 23.6596 24.4957 25.1228 25.5350 25.8827 26.4922 26.5603 26.7381 27.0662 27.8022 Columns 55 through 72 28.5689 28.8916 29.7903 29.9676 30.2870 30.3913 31.2978 31.7539 31.8617 32.4025 32.9641 33.1060 33.7096 33.8294 34.8254 35.6000 36.4209 37.2904 Columns 73 through 90 37.5798 38.0275 38.6606 38.9383 39.7610 40.1987 40.9295 41.4416 42.1434 43.0234 43.9797 44.5809 44.6571 45.1400 45.3309 45.8463 46.4353 46.4627 Columns 91 through 100 47.4047 47.7081 48.1847 48.4572 49.3151 50.2754 51.1049 51.9862 52.5390 53.3133 tf = logical 0

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

ic = Columns 1 through 18 0.5653 0.7798 1.0107 1.1308 2.0349 2.5179 2.6797 3.3777 4.0364 4.8607 5.3206 5.5888 6.5663 6.6228 6.9760 7.1973 7.6953 8.1674 Columns 19 through 36 8.8767 9.5583 9.8060 10.4027 11.3602 12.1657 12.7601 13.2647 14.1848 14.4111 14.6563 14.7968 15.0822 16.0056 16.2782 16.9901 17.1731 17.2074 Columns 37 through 50 17.3211 17.7844 18.6137 18.9197 19.7472 20.3692 20.6948 21.0045 21.6214 22.1971 23.1852 23.8564 24.7357 25.6140 tf = logical 1