Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 177806

Submitted on 15 Dec 2012 by Roberts
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));

b = 0 b = 0 b = 0 0 b = 0 0 0 b = 0 0 0 0 tf = 1

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

b = 0 tf = 1

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

b = 0 b = 1 b = 1 1 b = 1 1 1 b = 1 1 1 1 tf = 0

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

b = 0 b = 0 b = 0 0 b = 0 0 0 b = 0 0 0 1 tf = 0

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

b = 0 b = 1 b = 1 0 b = 1 0 0 b = 1 0 0 0 tf = 0

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

b = 0 b = 0 b = 0 0 b = 0 0 0 b = 0 0 0 0 b = 0 0 0 0 0 b = 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 17 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 18 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 19 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 20 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 21 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 22 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 23 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 24 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 25 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 26 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 27 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 28 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 33 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 34 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 35 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 36 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 37 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 38 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 39 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 40 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 41 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 42 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 43 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 49 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 50 ...

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

b = 0 b = 0 b = 0 0 b = 0 0 0 b = 0 0 0 1 b = 0 0 0 1 0 b = 0 0 0 1 0 0 b = 0 0 0 1 0 0 0 b = 0 0 0 1 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Column 17 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 18 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 19 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 20 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 21 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 22 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 23 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 24 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 25 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 26 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 27 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 28 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 33 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 34 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 35 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 36 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 37 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 38 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 39 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 40 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 41 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 42 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 43 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 44 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 46 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 49 0 b = Columns 1 through 16 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 33 through 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 49 through 50 ...

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

b = 0 b = 0 b = 0 0 b = 0 0 0 b = 0 0 0 0 b = 0 0 0 0 0 b = 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 17 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 18 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 19 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 20 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 21 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 22 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 23 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 24 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 25 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 26 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 27 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 28 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 33 0 b = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0