Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1900653

Submitted on 15 Aug 2019 by John Johni
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));

x1 = 0 1 2 3 4 tf = logical 1

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

x1 = 0 tf = logical 1

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

x1 = 0 0 0 0 0 tf = logical 1

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

x1 = -4 0 1 2 3

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

x1 = -4 -3 2 3 4

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

x1 = 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));

x1 = Columns 1 through 18 -1.0000 0.7183 1.3338 2.0513 2.3124 3.1060 3.6321 3.8148 4.6791 5.1301 6.1210 6.1314 6.4171 7.0761 7.6891 8.2466 9.2465 9.6452 Columns 19 through 36 9.8642 10.6990 10.8684 11.6039 11.9609 12.6632 12.9300 13.5907 13.6412 13.8737 14.4935 14.8304 15.7124 16.4431 17.0230 17.7770 18.3668 19.0744 Columns 37 through 54 19.6157 20.3677 20.9113 21.1358 21.7234 21.9511 22.7293 23.0227 23.1192 23.4560 23.7389 24.1986 24.9707 25.2711 25.6003 26.2165 26.5237 27.0646 Columns 55 through 72 27.3790 28.0386 28.8863 29.3479 29.9905 30.7716 31.1028 32.0103 32.6283 33.4747 34.0261 34.8430 35.4848 35.6878 35.9240 36.7472 37.3179 37.9329 Columns 73 through 90 38.0010 38.5162 38.9589 39.6858 40.6617 41.4073 41.9725 42.8120 43.1619 43.4509 43.6682 44.0561 44.2856 44.8876 45.7550 46.6032 47.2133 47.2637 Columns 91 through 100 47.8119 48.2407 48.5112 49.1126 49.6614 50.1729 50.9025 51.6594 52.0248 52.4787

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

x1 = Columns 1 through 18 0.8058 1.4852 1.7767 2.6177 3.2253 3.2726 3.9389 4.6359 5.4890 5.6664 6.0714 6.3199 6.8079 7.5315 7.9948 8.3344 8.3581 8.6054 Columns 19 through 36 8.6318 9.5766 9.7002 10.0791 10.3522 11.2216 11.4031 12.3784 12.8905 13.0978 13.4443 13.7845 13.8017 14.1974 15.1609 15.5824 16.3402 16.6417 Columns 37 through 50 16.7707 17.3903 17.6541 18.3113 18.7848 19.0632 19.9883 20.9685 21.7394 22.0754 22.5635 23.1728 24.1166 24.5787 tf = logical 1