Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 2075981

Submitted on 1 Jan 2020 by Carlo Venettacci
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));

x = -Inf 0 1 2 3 4

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

x = -Inf 0

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

x = -Inf 0 0 0 0 0 tf = logical 0

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

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

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

x = -Inf -3 -4 2 3 4 tf = logical 0

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

x = Columns 1 through 18 -Inf 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 Columns 19 through 36 2.7000 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 Columns 37 through 54 4.5000 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 Columns 55 through 72 6.3000 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 Columns 73 through 90 8.1000 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 Columns 91 through 92 9.9000 10.0000

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

x = Columns 1 through 18 -Inf 0.5839 1.3482 1.5040 2.4598 -1.0000 3.1068 3.9575 4.8208 5.3187 5.6518 6.3577 7.0896 7.5307 8.4684 9.0216 9.7005 9.9668 Columns 19 through 36 10.1247 10.6854 10.7301 11.1254 11.3313 12.0973 13.0928 13.4203 14.3281 15.0264 15.1253 15.7157 16.4637 16.5301 16.9840 17.9825 18.1346 18.1358 Columns 37 through 54 19.0014 19.3538 19.7640 19.9073 20.1053 21.0385 21.0962 21.9972 22.0763 22.6309 23.2124 24.2015 24.6727 24.9421 25.2255 26.2132 27.1343 27.9753 Columns 55 through 72 28.3303 29.2150 29.7797 30.0430 30.7651 31.7026 32.2704 33.2160 34.1534 34.4151 34.9474 35.3267 36.0315 36.8134 36.9747 37.4842 37.9128 38.7498 Columns 73 through 90 39.3207 40.1802 40.2254 40.9676 41.5842 41.8322 42.2195 42.4964 43.2348 43.2627 43.3820 43.4437 44.0373 44.5106 45.0409 45.6198 45.7731 46.2092 Columns 91 through 101 46.7606 46.7636 47.2391 47.5025 48.4531 49.1174 49.5539 50.5512 51.1766 51.8426 52.5821 tf = logical 0

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

x = Columns 1 through 18 -Inf 0.5116 0.7125 0.7252 1.7194 1.9025 1.9314 2.7584 3.2086 3.9210 4.0787 4.7789 5.3441 5.6079 6.3155 6.4858 6.7777 6.7804 Columns 19 through 36 7.7461 8.3806 8.5717 9.5022 10.3243 10.6747 11.4936 12.0940 12.6034 13.1352 14.0518 14.4788 14.6378 14.6586 15.0200 15.7390 16.1822 16.1863 Columns 37 through 51 16.5453 16.6280 16.8501 17.1631 17.4859 18.0739 18.3299 18.8445 19.7308 20.1979 20.3177 20.7766 21.1012 21.3979 22.0978

### Community Treasure Hunt

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

Start Hunting!