Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1847931

Submitted on 12 Jun 2019 by Ryan Wilcox
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));

hold = 0 hold = 1 hold = 2 hold = 3 hold = 4

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

hold = 0

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

hold = 0 tf = logical 0 hold = 0 tf = logical 0 hold = 0 tf = logical 0 hold = 0 tf = logical 0 hold = 0

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

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

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

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

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

hold = 1 hold = 1.1000 hold = 1.2000 hold = 1.3000 hold = 1.4000 hold = 1.5000 hold = 1.6000 hold = 1.7000 hold = 1.8000 hold = 1.9000 hold = 2 hold = 2.1000 hold = 2.2000 hold = 2.3000 hold = 2.4000 hold = 2.5000 hold = 2.6000 hold = 2.7000 hold = 2.8000 hold = 2.9000 hold = 3 hold = 3.1000 hold = 3.2000 hold = 3.3000 hold = 3.4000 hold = 3.5000 hold = 3.6000 hold = 3.7000 hold = 3.8000 hold = 3.9000 hold = 4 hold = 4.1000 hold = 4.2000 hold = 4.3000 hold = 4.4000 hold = 4.5000 hold = 4.6000 hold = 4.7000 hold = 4.8000 hold = 4.9000 hold = 5 hold = 5.1000 hold = 5.2000 hold = 5.3000 hold = 5.4000 hold = 5.5000 hold = 5.6000 hold = 5.7000 hold = 5.8000 hold = 5.9000 hold = 6 hold = 6.1000 hold = 6.2000 hold = 6.3000 hold = 6.4000 hold = 6.5000 hold = 6.6000 hold = 6.7000 hold = 6.8000 hold = 6.9000 hold = 7 hold = 7.1000 hold = 7.2000 hold = 7.3000 hold = 7.4000 hold = 7.5000 hold = 7.6000 hold = 7.7000 hold = 7.8000 hold = 7.9000 hold = 8 hold = 8.1000 hold = 8.2000 hold = 8.3000 hold = 8.4000 hold = 8.5000 hold = 8.6000 hold = 8.7000 hold = 8.8000 hold = 8.9000 hold = 9 hold = 9.1000 hold = 9.2000 hold = 9.3000 hold = 9.4000 hold = 9.5000 hold = 9.6000 hold = 9.7000 hold = 9.8000 hold = 9.9000 hold = 10

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

hold = 0.7124 hold = 1.5676 hold = 2.0018 hold = 2.2457 tf = logical 0 hold = -1 hold = 3.6959 hold = 3.9343 hold = 3.9890 hold = 4.5841 hold = 4.8530 hold = 5.5854 hold = 6.2530 hold = 6.9702 hold = 7.5970 hold = 8.5232 hold = 8.5301 hold = 9.4846 hold = 10.2473 hold = 11.0682 hold = 12.0033 hold = 12.0577 hold = 12.1866 hold = 12.4582 hold = 13.3654 hold = 13.7659 hold = 14.0645 hold = 14.5849 hold = 14.9846 hold = 15.7560 hold = 16.6454 hold = 17.6267 hold = 18.1999 hold = 18.4578 hold = 18.9482 hold = 19.7155 hold = 20.6816 hold = 20.9059 hold = 21.3360 hold = 21.4241 hold = 21.9406 hold = 22.1990 hold = 23.0052 hold = 23.8303 hold = 24.7893 hold = 25.5339 hold = 25.7006 hold = 26.0674 hold = 26.3990 hold = 26.4299 hold = 26.5196 hold = 27.4820 hold = 27.5057 hold = 27.9268 hold = 28.7308 hold = 29.5985 hold = 29.8121 hold = 29.9071 hold = 29.9384 hold = 30.6983 hold = 30.9649 hold = 31.6154 hold = 31.6475 hold = 31.8699 hold = 32.7045 hold = 33.4357 hold = 34.3272 hold = 35.0592 hold = 35.3911 hold = 35.5978 hold = 36.0586 hold = 36.6524 hold = 37.3208 hold = 37.4232 hold = 38.3310 hold = 38.7721 hold = 39.3340 hold = 39.3504 hold = 40.1201 hold = 40.9211 hold = 41.1082 hold = 42.0773 hold = 42.9305 hold = 43.4384 hold = 43.9921 hold = 44.6271 hold = 45.3586 hold = 45.8778 hold = 46.6179 hold = 47.0292 hold = 47.8135 hold = 48.6652 hold = 48.8450 hold = 49.8263 hold = 50.7765 hold = 51.2431 hold = 51.4101 hold = 52.2795 hold = 52.6525 hold = 52.6972 hold = 53.3147

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

hold = 0.6633 hold = 1.6495 hold = 2.6285 hold = 3.3481 hold = 3.5203 hold = 4.0214 hold = 4.2467 hold = 5.1315 hold = 5.4582 hold = 5.8753 hold = 5.8815 hold = 6.2858 hold = 6.3661 hold = 6.6538 hold = 7.2074 hold = 7.8672 hold = 7.9192 hold = 8.2977 hold = 9.1039 hold = 9.7847 hold = 10.3744 hold = 10.8267 hold = 11.5779 hold = 11.7590 hold = 12.0302 hold = 12.1490 hold = 12.8678 hold = 13.3240 hold = 14.2692 hold = 15.0407 hold = 15.6976 hold = 16.4736 hold = 16.5934 hold = 16.9088 hold = 17.4439 hold = 17.6841 hold = 17.9104 hold = 18.0854 hold = 18.3737 hold = 18.5687 hold = 18.7596 hold = 19.6342 hold = 20.0440 hold = 20.0657 hold = 20.3308 hold = 20.3973 hold = 20.4122 hold = 21.3123 hold = 21.5821 hold = 21.9352