Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1362965

Submitted on 30 Nov 2017 by cruxjello Late
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));

y = 0 1 2 3 4 x = 1 2 3 4 x = 1 2 3 4 5 tf = logical 1

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

tf = logical 1

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

y = 0 0 0 0 0 x = 0 0 0 0 x = 0 0 0 0 1 tf = logical 0

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

y = 0 1 2 3 -4 x = 1 2 3 -4 x = 1 2 3 -4 -3 tf = logical 0

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

y = -3 -4 2 3 4 x = -4 2 3 4 x = -4 2 3 4 5 tf = logical 0

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

y = 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 x = Columns 1 through 18 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 2.8000 Columns 19 through 36 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 4.6000 Columns 37 through 54 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 6.4000 Columns 55 through 72 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 8.2000 Columns 73 through 90 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 10.0000 x = Columns 1 through 18 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 2.8000 Columns 19 through 36 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 4.6000 Columns 37 through 54 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 6.4000 Columns 55 through 72 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 8.2000 Columns 73 through 90 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 10.0000 Column 91 11.0000 tf = logical 1

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

y = Columns 1 through 18 0.2951 0.4704 0.8974 1.0638 -1.0000 1.9678 2.9082 3.1151 4.0288 4.3406 5.3324 5.6269 6.3124 7.2160 8.1303 8.5476 9.4136 9.4406 Columns 19 through 36 9.4897 9.8727 10.7551 10.9064 11.6176 11.7808 12.1015 12.1225 12.1866 12.5192 12.6754 12.8195 13.7128 14.2846 15.0896 15.2501 15.6951 16.2525 Columns 37 through 54 16.5530 17.0238 17.8122 17.9615 18.0721 18.3592 18.8316 19.1355 19.7758 20.2997 20.8159 21.0590 21.1083 21.4709 21.8560 22.3110 22.9758 23.6273 Columns 55 through 72 24.2877 24.7077 25.4122 26.2161 26.5387 26.7820 26.8747 27.1536 27.5030 28.1817 28.6414 29.4198 30.0825 31.0521 32.0392 32.9829 33.1062 33.3700 Columns 73 through 90 34.1672 34.7681 35.5664 35.6087 36.5577 36.5658 36.8815 37.6884 37.8102 38.0121 38.0777 38.5437 39.3500 39.8675 40.3190 40.5289 41.5220 41.7320 Columns 91 through 100 42.1342 42.7934 43.7136 43.8155 44.6778 44.9751 45.0022 45.5183 46.4948 46.8155 x = Columns 1 through 18 0.4704 0.8974 1.0638 -1.0000 1.9678 2.9082 3.1151 4.0288 4.3406 5.3324 5.6269 6.3124 7.2160 8.1303 8.5476 9.4136 9.4406 9.4897 Columns 19 through 36 9.8727 10.7551 10.9064 11.6176 11.7808 12.1015 12.1225 12.1866 12.5192 12.6754 12.8195 13.7128 14.2846 15.0896 15.2501 15.6951 16.2525 16.5530 Columns 37 through 54 17.0238 17.8122 17.9615 18.0721 18.3592 18.8316 19.1355 19.7758 20.2997 20.8159 21.0590 21.1083 21.4709 21.8560 22.3110 22.9758 23.6273 24.2877 Columns 55 through 72 24.7077 25.4122 26.2161 26.5387 26.7820 26.8747 27.1536 27.5030 28.1817 28.6414 29.4198 30.0825 31.0521 32.0392 32.9829 33.1062 33.3700 34.1672 Columns 73 through 90 34.7681 35.5664 35.6087 36.5577 36.5658 36.8815 37.6884 37.8102 38.0121 38.0777 38.5437 39.3500 39.8675 40.3190 40.5289 41.5220 41.7320 42.1342 Columns 91 through 99 42.7934 43.7136 43.8155 44.6778 44.9751 45.0022 45.5183 46.4948 46.8155 x = Columns 1 through 18 0.4704 0.8974 1.0638 -1.0000 1.9678 2.9082 3.1151 4.0288 4.3406 5.3324 5.6269 6.3124 7.2160 8.1303 8.5476 9.4136 9.4406 9.4897 Columns 19 through 36 9.8727 10.7551 10.9064 11.6176 11.7808 12.1015 12.1225 12.1866 12.5192 12.6754 12.8195 13.7128 14.2846 15.0896 15.2501 15.6951 16.2525 16.5530 Columns 37 through 54 17.0238 17.8122 17.9615 18.0721 18.3592 18.8316 19.1355 19.7758 20.2997 20.8159 21.0590 21.1083 21.4709 21.8560 22.3110 22.9758 23.6273 24.2877 Columns 55 through 72 24.7077 25.4122 26.2161 26.5387 26.7820 26.8747 27.1536 27.5030 28.1817 28.6414 29.4198 30.0825 31.0521 32.0392 32.9829 33.1062 33.3700 34.1672 Columns 73 through 90 34.7681 35.5664 35.6087 36.5577 36.5658 36.8815 37.6884 37.8102 38.0121 38.0777 38.5437 39.3500 39.8675 40.3190 40.5289 41.5220 41.7320 42.1342 Columns 91 through 100 42.7934 43.7136 43.8155 44.6778 44.9751 45.0022 45.5183 46.4948 46.8155 47.8155 tf = logical 0

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

y = Columns 1 through 18 0.5170 0.6921 0.7044 1.5603 1.6812 1.7781 2.5579 3.3541 3.6996 3.8391 4.7582 5.2858 5.5070 6.1087 6.2674 7.1631 7.5008 8.3725 Columns 19 through 36 9.0222 9.1741 9.5437 10.3981 11.1089 11.2748 11.8105 12.1884 13.0775 13.3186 13.3654 13.5562 14.0957 14.3372 15.2746 15.5442 16.1945 16.5209 Columns 37 through 50 17.4252 18.3231 18.4772 18.8451 19.6852 20.1969 20.9803 21.9104 22.8280 23.3110 23.5478 23.7488 24.6729 24.9613 x = Columns 1 through 18 0.6921 0.7044 1.5603 1.6812 1.7781 2.5579 3.3541 3.6996 3.8391 4.7582 5.2858 5.5070 6.1087 6.2674 7.1631 7.5008 8.3725 9.0222 Columns 19 through 36 9.1741 9.5437 10.3981 11.1089 11.2748 11.8105 12.1884 13.0775 13.3186 13.3654 13.5562 14.0957 14.3372 15.2746 15.5442 16.1945 16.5209 17.4252 Columns 37 through 49 18.3231 18.4772 18.8451 19.6852 20.1969 20.9803 21.9104 22.8280 23.3110 23.5478 23.7488 24.6729 24.9613 x = Columns 1 through 18 0.6921 0.7044 1.5603 1.6812 1.7781 2.5579 3.3541 3.6996 3.8391 4.7582 5.2858 5.5070 6.1087 6.2674 7.1631 7.5008 8.3725 9.0222 Columns 19 through 36 9.1741 9.5437 10.3981 11.1089 11.2748 11.8105 12.1884 13.0775 13.3186 13.3654 13.5562 14.0957 14.3372 15.2746 15.5442 16.1945 16.5209 17.4252 Columns 37 through 50 18.3231 18.4772 18.8451 19.6852 20.1969 20.9803 21.9104 22.8280 23.3110 23.5478 23.7488 24.6729 24.9613 25.9613 tf = logical 1