Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 2657795

Submitted on 6 Jul 2020 by Ze Li Liew
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));

max_x = 1 max_x = 2 max_x = 3 max_x = 4

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

max_x = 1 max_x = 2 max_x = 3

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

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

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

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

max_x = 0.5678 max_x = 1.0246 max_x = 1.7095

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

max_x = 0.3892 max_x = 0.8833 max_x = 1.2287 max_x = 1.3328 max_x = 1.7074 max_x = 2.0565 max_x = 2.2497 max_x = 2.7053 max_x = 2.8875 max_x = 3.3151 max_x = 3.9317 max_x = 4.1160 max_x = 4.8950 max_x = 4.9011 max_x = 4.9215 max_x = 5.2987 max_x = 5.9838 max_x = 6.9138 max_x = 7.0348 max_x = 7.1036 max_x = 7.5460 max_x = 8.4640 max_x = 9.2834 max_x = 10.1895 max_x = 11.1482 max_x = 11.8037 max_x = 11.9892 max_x = 12.4033 max_x = 12.4920 max_x = 13.2888 max_x = 13.8876 max_x = 14.6770 max_x = 15.0475 max_x = 15.7833 max_x = 15.9921 max_x = 16.9233 max_x = 17.4515 max_x = 18.3329 max_x = 18.4499 max_x = 18.8618 max_x = 19.0663 max_x = 19.1625 max_x = 19.6253 max_x = 19.7017 max_x = 20.1055 max_x = 20.1456 max_x = 21.0585 max_x = 21.5198 max_x = 22.1738

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!