Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 2050131

Submitted on 8 Dec 2019 by ohman
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));

t = 0 1 2 3 4 t = 0 1 2 3 4 tf = logical 1

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

t = 0 t = 0 tf = logical 1

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

t = 0 0 0 0 0 t = 0 tf = logical 0

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

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

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

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

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

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

t = Columns 1 through 18 -1.0000 0.4139 1.1468 1.7715 2.6487 3.7563 3.9884 4.3440 5.3239 5.5157 5.7568 6.4516 6.7220 7.6933 8.4137 9.3267 9.4156 9.4547 Columns 19 through 36 9.9420 10.4325 10.9189 11.6794 11.7025 11.8813 12.6863 13.0114 13.9361 14.9134 15.3247 15.3766 15.4804 15.6472 16.6235 16.9755 17.1709 17.6077 Columns 37 through 54 18.3154 18.7803 19.1913 19.3388 20.1744 21.1655 22.1526 22.6141 23.0224 23.0314 23.3953 23.7273 24.0579 24.2196 24.5852 24.7477 25.3533 26.1696 Columns 55 through 72 26.8705 27.3981 27.7807 28.7574 28.9888 29.3258 30.0772 30.2940 30.9984 31.7246 32.3713 32.5770 33.2005 33.5948 34.4397 35.0851 35.7938 36.3863 Columns 73 through 90 37.2481 37.5736 38.1665 38.3367 38.4671 39.0255 39.5174 39.9119 39.9416 40.2769 40.4363 40.8552 41.0446 41.6317 42.0683 42.5378 43.3885 44.2329 Columns 91 through 100 44.3963 45.1087 45.9818 46.7566 47.5091 47.9157 48.1918 48.9306 49.0227 49.7994 t = Columns 1 through 18 -1.0000 0.4139 1.1468 1.7715 2.6487 3.7563 3.9884 4.3440 5.3239 5.5157 5.7568 6.4516 6.7220 7.6933 8.4137 9.3267 9.4156 9.4547 Columns 19 through 36 9.9420 10.4325 10.9189 11.6794 11.7025 11.8813 12.6863 13.0114 13.9361 14.9134 15.3247 15.3766 15.4804 15.6472 16.6235 16.9755 17.1709 17.6077 Columns 37 through 54 18.3154 18.7803 19.1913 19.3388 20.1744 21.1655 22.1526 22.6141 23.0224 23.0314 23.3953 23.7273 24.0579 24.2196 24.5852 24.7477 25.3533 26.1696 Columns 55 through 72 26.8705 27.3981 27.7807 28.7574 28.9888 29.3258 30.0772 30.2940 30.9984 31.7246 32.3713 32.5770 33.2005 33.5948 34.4397 35.0851 35.7938 36.3863 Columns 73 through 90 37.2481 37.5736 38.1665 38.3367 38.4671 39.0255 39.5174 39.9119 39.9416 40.2769 40.4363 40.8552 41.0446 41.6317 42.0683 42.5378 43.3885 44.2329 Columns 91 through 100 44.3963 45.1087 45.9818 46.7566 47.5091 47.9157 48.1918 48.9306 49.0227 49.7994 tf = logical 0

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

t = Columns 1 through 18 0.1691 0.3291 0.9405 1.7770 1.8727 2.6014 3.2082 3.9055 4.4580 5.1090 5.9554 6.9551 7.9382 8.5539 9.2304 9.5171 9.6279 9.7247 Columns 19 through 36 9.8279 10.3884 11.1384 11.2827 12.2055 13.0768 13.5185 14.3851 15.1319 15.4535 15.7573 15.7968 16.3241 17.2897 17.3963 18.2394 19.0158 19.7040 Columns 37 through 50 20.4408 21.1192 21.4936 22.2652 22.7740 23.3172 23.4833 24.1242 24.8078 24.8707 25.7104 26.2298 26.6407 26.7610 t = Columns 1 through 18 0.1691 0.3291 0.9405 1.7770 1.8727 2.6014 3.2082 3.9055 4.4580 5.1090 5.9554 6.9551 7.9382 8.5539 9.2304 9.5171 9.6279 9.7247 Columns 19 through 36 9.8279 10.3884 11.1384 11.2827 12.2055 13.0768 13.5185 14.3851 15.1319 15.4535 15.7573 15.7968 16.3241 17.2897 17.3963 18.2394 19.0158 19.7040 Columns 37 through 50 20.4408 21.1192 21.4936 22.2652 22.7740 23.3172 23.4833 24.1242 24.8078 24.8707 25.7104 26.2298 26.6407 26.7610 tf = logical 1