Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 2242027

Submitted on 28 Apr 2020 by Andrzej Mamczura
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 m = 0 n = 1 t = 1 m = 1 n = 2 t = 2 m = 2 n = 3 t = 3 m = 3 n = 4 t = 4 tf = logical 1

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

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

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

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

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

t = 0 m = 1 n = 1.1000 t = 1 m = 1.1000 n = 1.2000 t = 2 m = 1.2000 n = 1.3000 t = 3 m = 1.3000 n = 1.4000 t = 4 m = 1.4000 n = 1.5000 t = 5 m = 1.5000 n = 1.6000 t = 6 m = 1.6000 n = 1.7000 t = 7 m = 1.7000 n = 1.8000 t = 8 m = 1.8000 n = 1.9000 t = 9 m = 1.9000 n = 2 t = 10 m = 2 n = 2.1000 t = 11 m = 2.1000 n = 2.2000 t = 12 m = 2.2000 n = 2.3000 t = 13 m = 2.3000 n = 2.4000 t = 14 m = 2.4000 n = 2.5000 t = 15 m = 2.5000 n = 2.6000 t = 16 m = 2.6000 n = 2.7000 t = 17 m = 2.7000 n = 2.8000 t = 18 m = 2.8000 n = 2.9000 t = 19 m = 2.9000 n = 3 t = 20 m = 3 n = 3.1000 t = 21 m = 3.1000 n = 3.2000 t = 22 m = 3.2000 n = 3.3000 t = 23 m = 3.3000 n = 3.4000 t = 24 m = 3.4000 n = 3.5000 t = 25 m = 3.5000 n = 3.6000 t = 26 m = 3.6000 n = 3.7000 t = 27 m = 3.7000 n = 3.8000 t = 28 m = 3.8000 n = 3.9000 t = 29 m = 3.9000 n = 4 t = 30 m = 4 n = 4.1000 t = 31 m = 4.1000 n = 4.2000 t = 32 m = 4.2000 n = 4.3000 t = 33 m = 4.3000 n = 4.4000 t = 34 m = 4.4000 n = 4.5000 t = 35 m = 4.5000 n = 4.6000 t = 36 m = 4.6000 n = 4.7000 t = 37 m = 4.7000 n = 4.8000 t = 38 m = 4.8000 n = 4.9000 t = 39 m = 4.9000 n = 5 t = 40 m = 5 n = 5.1000 t = 41 m = 5.1000 n = 5.2000 t = 42 m = 5.2000 n = 5.3000 t = 43 m = 5.3000 n = 5.4000 t = 44 m = 5.4000 n = 5.5000 t = 45 m = 5.5000 n = 5.6000 t = 46 m = 5.6000 n = 5.7000 t = 47 m = 5.7000 n = 5.8000 t = 48 m = 5.8000 n = 5.9000 t = 49 m = 5.9000 n = 6 t = 50 m = 6 n = 6.1000 t = 51 m = 6.1000 n = 6.2000 t = 52 m = 6.2000 n = 6.3000 t = 53 m = 6.3000 n = 6.4000 t = 54 m = 6.4000 n = 6.5000 t = 55 m = 6.5000 n = 6.6000 t = 56 m = 6.6000 n = 6.7000 t = 57 m = 6.7000 n = 6.8000 t = 58 m = 6.8000 n = 6.9000 t = 59 m = 6.9000 n = 7 t = 60 m = 7 n = 7.1000 t = 61 m = 7.1000 n = 7.2000 t = 62 m = 7.2000 n = 7.3000 t = 63 m = 7.3000 n = 7.4000 t = 64 m = 7.4000 n = 7.5000 t = 65 m = 7.5000 n = 7.6000 t = 66 m = 7.6000 n = 7.7000 t = 67 m = 7.7000 n = 7.8000 t = 68 m = 7.8000 n = 7.9000 t = 69 m = 7.9000 n = 8 t = 70 m = 8 n = 8.1000 t = 71 m = 8.1000 n = 8.2000 t = 72 m = 8.2000 n = 8.3000 t = 73 m = 8.3000 n = 8.4000 t = 74 m = 8.4000 n = 8.5000 t = 75 m = 8.5000 n = 8.6000 t = 76 m = 8.6000 n = 8.7000 t = 77 m = 8.7000 n = 8.8000 t = 78 m = 8.8000 n = 8.9000 t = 79 m = 8.9000 n = 9 t = 80 m = 9 n = 9.1000 t = 81 m = 9.1000 n = 9.2000 t = 82 m = 9.2000 n = 9.3000 t = 83 m = 9.3000 n = 9.4000 t = 84 m = 9.4000 n = 9.5000 t = 85 m = 9.5000 n = 9.6000 t = 86 m = 9.6000 n = 9.7000 t = 87 m = 9.7000 n = 9.8000 t = 88 m = 9.8000 n = 9.9000 t = 89 m = 9.9000 n = 10 t = 90 tf = logical 1

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

t = 0 m = 0.4041 n = 1.3017 t = 1 m = 1.3017 n = 1.8829 t = 2 m = 1.8829 n = 2.2223 t = 3 m = 2.2223 n = -1 t = 3 m = -1 n = 3.1647 t = 4 m = 3.1647 n = 3.6710 t = 5 m = 3.6710 n = 4.2094 t = 6 m = 4.2094 n = 4.7092 t = 7 m = 4.7092 n = 5.6171 t = 8 m = 5.6171 n = 6.1295 t = 9 m = 6.1295 n = 6.7624 t = 10 m = 6.7624 n = 7.3246 t = 11 m = 7.3246 n = 7.4220 t = 12 m = 7.4220 n = 8.2339 t = 13 m = 8.2339 n = 8.9828 t = 14 m = 8.9828 n = 9.9199 t = 15 m = 9.9199 n = 10.9176 t = 16 m = 10.9176 n = 11.4974 t = 17 m = 11.4974 n = 11.9059 t = 18 m = 11.9059 n = 12.3960 t = 19 m = 12.3960 n = 13.1187 t = 20 m = 13.1187 n = 14.0612 t = 21 m = 14.0612 n = 14.8506 t = 22 m = 14.8506 n = 15.1200 t = 23 m = 15.1200 n = 15.1650 t = 24 m = 15.1650 n = 16.0274 t = 25 m = 16.0274 n = 16.1745 t = 26 m = 16.1745 n = 16.2305 t = 27 m = 16.2305 n = 16.4221 t = 28 m = 16.4221 n = 16.7853 t = 29 m = 16.7853 n = 17.4023 t = 30 m = 17.4023 n = 17.4311 t = 31 m = 17.4311 n = 17.6510 t = 32 m = 17.6510 n = 17.9514 t = 33 m = 17.9514 n = 18.8302 t = 34 m = 18.8302 n = 19.3987 t = 35 m = 19.3987 n = 20.1552 t = 36 m = 20.1552 n = 20.4879 t = 37 m = 20.4879 n = 20.9437 t = 38 m = 20.9437 n = 21.8367 t = 39 m = 21.8367 n = 22.0348 t = 40 m = 22.0348 n = 23.0017 t = 41 m = 23.0017 n = 23.0041 t = 42 m = 23.0041 n = 23.5137 t = 43 m = 23.5137 n = 23.9361 t = 44 m = 23.9361 n = 24.1587 t = 45 m = 24.1587 n = 24.1953 t = 46 m = 24.1953 n = 24.7122 t = 47 m = 24.7122 n = 25.4823 t = 48 m = 25.4823 n = 25.6299 t = 49 m = 25.6299 n = 25.8429 t = 50 m = 25.8429 n = 26.3227 t = 51 m = 26.3227 n = 26.7763 t = 52 m = 26.7763 n = 27.5176 t = 53 m = 27.5176 n = 27.6291 t = 54 m = 27.6291 n = 28.2124 t = 55 m = 28.2124 n = 29.2099 t = 56 m = 29.2099 n = 29.2154 t = 57 m = 29.2154 n = 29.9006 t = 58 m = 29.9006 n = 30.2812 t = 59 m = 30.2812 n = 30.9905 t = 60 m = 30.9905 n = 31.9081 t = 61 m = 31.9081 n = 32.5084 t = 62 m = 32.5084 n = 33.0917 t = 63 m = 33.0917 n = 33.1956 t = 64 m = 33.1956 n = 33.3205 t = 65 m = 33.3205 n = 33.8208 t = 66 m = 33.8208 n = 34.4513 t = 67 m = 34.4513 n = 34.8258 t = 68 m = 34.8258 n = 35.1683 t = 69 m = 35.1683 n = 35.8092 t = 70 m = 35.8092 n = 36.7570 t = 71 m = 36.7570 n = 37.0463 t = 72 m = 37.0463 n = 37.6894 t = 73 m = 37.6894 n = 38.1657 t = 74 m = 38.1657 n = 38.2492 t = 75 m = 38.2492 n = 38.6588 t = 76 m = 38.6588 n = 39.4007 t = 77 m = 39.4007 n = 40.3105 t = 78 m = 40.3105 n = 40.7728 t = 79 m = 40.7728 n = 40.7968 t = 80 m = 40.7968 n = 41.0830 t = 81 m = 41.0830 n = 41.4299 t = 82 m = 41.4299 n = 41.6934 t = 83 m = 41.6934 n = 42.1384 t = 84 m = 42.1384 n = 42.3741 t = 85 m = 42.3741 n = 42.5556 t = 86 m = 42.5556 n = 42.9274 t = 87 m = 42.9274 n = 42.9672 t = 88 m = 42.9672 n = 43.8198 t = 89 m = 43.8198 n = 44.7847 t = 90 m = 44.7847 n = 45.2506 t = 91 m = 45.2506 n = 46.0998 t = 92 m = 46.0998 n = 46.9519 t = 93 m = 46.9519 n = 47.0007 t = 94 m = 47.0007 n = 47.8584 t = 95 m = 47.8584 n = 48.6551 t = 96 m = 48.6551 n = 49.3426 t = 97 m = 49.3426 n = 49.3885 t = 98 tf = logical 0

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

t = 0 m = 0.7026 n = 1.5351 t = 1 m = 1.5351 n = 2.0589 t = 2 m = 2.0589 n = 2.2043 t = 3 m = 2.2043 n = 3.1760 t = 4 m = 3.1760 n = 3.5541 t = 5 m = 3.5541 n = 3.7203 t = 6 m = 3.7203 n = 4.3732 t = 7 m = 4.3732 n = 4.9666 t = 8 m = 4.9666 n = 5.3325 t = 9 m = 5.3325 n = 5.5282 t = 10 m = 5.5282 n = 6.0000 t = 11 m = 6.0000 n = 6.3882 t = 12 m = 6.3882 n = 7.1095 t = 13 m = 7.1095 n = 7.9338 t = 14 m = 7.9338 n = 8.5006 t = 15 m = 8.5006 n = 9.4583 t = 16 m = 9.4583 n = 10.4065 t = 17 m = 10.4065 n = 10.7507 t = 18 m = 10.7507 n = 11.5439 t = 19 m = 11.5439 n = 12.2667 t = 20 m = 12.2667 n = 12.9348 t = 21 m = 12.9348 n = 13.0926 t = 22 m = 13.0926 n = 13.9043 t = 23 m = 13.9043 n = 14.7360 t = 24 m = 14.7360 n = 15.4092 t = 25 m = 15.4092 n = 16.0825 t = 26 m = 16.0825 n = 16.4462 t = 27 m = 16.4462 n = 17.1248 t = 28 m = 17.1248 n = 17.6196 t = 29 m = 17.6196 n = 18.3303 t = 30 m = 18.3303 n = 19.0561 t = 31 m = 19.0561 n = 19.8477 t = 32 m = 19.8477 n = 19.8911 t = 33 m = 19.8911 n = 20.3628 t = 34 m = 20.3628 n = 21.2123 t = 35 m = 21.2123 n = 21.9885 t = 36 m = 21.9885 n = 22.1337 t = 37 m = 22.1337 n = 22.5601 t = 38 m = 22.5601 n = 23.0121 t = 39 m = 23.0121 n = 23.6890 t = 40 m = 23.6890 n = 24.6261 t = 41 m = 24.6261 n = 24.6766 t = 42 m = 24.6766 n = 24.8462 t = 43 m = 24.8462 n = 24.9482 t = 44 m = 24.9482 n = 25.4378 t = 45 m = 25.4378 n = 25.4561 t = 46 m = 25.4561 n = 25.7750 t = 47 m = 25.7750 n = 26.6340 t = 48 m = 26.6340 n = 26.8464 t = 49 tf = logical 1

### Community Treasure Hunt

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

Start Hunting!