Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 179042

Submitted on 18 Dec 2012 by John Booker
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));

diff = 1 1 1 1 tf = 1

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

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

diff = 0 0 0 0 tf = 0

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

diff = 1 1 1 -7 tf = 0

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

diff = -1 6 1 1 tf = 0

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

diff = Columns 1 through 10 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 11 through 20 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 21 through 30 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 31 through 40 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 41 through 50 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 51 through 60 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 61 through 70 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 71 through 80 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 81 through 90 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 tf = 1

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

diff = Columns 1 through 10 0.0589 0.1048 0.0688 -1.3620 2.1656 0.3308 0.1494 0.8743 0.5745 0.9949 Columns 11 through 20 0.2668 0.2296 0.5056 0.4459 0.5854 0.8384 0.3976 0.8004 0.2861 0.1408 Columns 21 through 30 0.7360 0.0608 0.6998 0.6001 0.0336 0.9319 0.9750 0.5107 0.1435 0.1631 Columns 31 through 40 0.1144 0.4526 0.5353 0.8201 0.8435 0.3026 0.8676 0.5063 0.5731 0.1339 Columns 41 through 50 0.9275 0.0071 0.2002 0.1738 0.9737 0.6148 0.4853 0.5467 0.6980 0.1280 Columns 51 through 60 0.3590 0.2846 0.8864 0.1615 0.4110 0.7014 0.3910 0.8329 0.8585 0.6977 Columns 61 through 70 0.3139 0.8497 0.8720 0.2499 0.9398 0.0196 0.1376 0.1648 0.0021 0.5009 Columns 71 through 80 0.8742 0.2852 0.2729 0.4765 0.0972 0.6826 0.8830 0.9208 0.9634 0.8639 Columns 81 through 90 0.8974 0.4895 0.2310 0.3744 0.1848 0.3335 0.5226 0.7890 0.6032 0.0656 Columns 91 through 99 0.6774 0.0528 0.2568 0.9892 0.8078 0.2493 0.4078 0.1788 0.7094 tf = 0

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

diff = Columns 1 through 10 0.3464 0.2959 0.2209 0.9149 0.3584 0.4911 0.2255 0.6970 0.8095 0.5563 Columns 11 through 20 0.2584 0.2299 0.2619 0.6194 0.0892 0.3138 0.2758 0.4733 0.0656 0.7813 Columns 21 through 30 0.2823 0.9353 0.9159 0.5754 0.9807 0.2613 0.3772 0.7823 0.9734 0.6606 Columns 31 through 40 0.0918 0.7806 0.5378 0.7412 0.9873 0.1800 0.1076 0.5472 0.2053 0.5858 Columns 41 through 49 0.8714 0.6450 0.5336 0.2203 0.3004 0.3672 0.8286 0.8257 0.5734 tf = 1