Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 40344

Submitted on 13 Feb 2012 by David Smith
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### Test Suite

Test Status Code Input and Output
1   Pass
%% x = [0 1 2 3 4]; assert(isequal(mono_increase(x),true));

delta = 1 1 1 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));

delta = 0 0 0 0 tf = 0

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

delta = 1 1 1 -7 tf = 0

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

delta = -1 6 1 1 tf = 0

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

delta = 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

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

delta = Columns 1 through 10 0.2867 0.9085 0.7849 -3.6029 5.4311 0.3359 0.6191 0.4655 0.1213 0.9362 Columns 11 through 20 0.5287 0.9121 0.2384 0.3230 0.6421 0.3900 0.0528 0.7889 0.6678 0.6172 Columns 21 through 30 0.0814 0.2668 0.6015 0.9541 0.2349 0.1778 0.3988 0.4254 0.6015 0.0915 Columns 31 through 40 0.9523 0.1876 0.9728 0.3607 0.9772 0.1408 0.2529 0.1835 0.4115 0.4885 Columns 41 through 50 0.7936 0.5752 0.4757 0.5381 0.0402 0.4615 0.7175 0.5974 0.9710 0.6626 Columns 51 through 60 0.1516 0.1297 0.9102 0.9198 0.1387 0.0493 0.2573 0.9412 0.3978 0.3840 Columns 61 through 70 0.7631 0.1593 0.8484 0.3350 0.6334 0.0312 0.6300 0.7783 0.4401 0.1087 Columns 71 through 80 0.0834 0.6248 0.3141 0.8495 0.0806 0.7596 0.6936 0.7039 0.1621 0.3277 Columns 81 through 90 0.7521 0.1157 0.8675 0.5526 0.8715 0.9751 0.6186 0.2754 0.0122 0.9554 Columns 91 through 99 0.6950 0.1514 0.6345 0.2044 0.9361 0.2274 0.1511 0.9865 0.9621 tf = 0

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

delta = Columns 1 through 10 0.4322 0.4794 0.8148 0.4203 0.0062 0.0846 0.4532 0.9627 0.2938 0.3330 Columns 11 through 20 0.7206 0.1438 0.7563 0.8251 0.6732 0.2117 0.9969 0.8719 0.8066 0.4976 Columns 21 through 30 0.5287 0.2259 0.5228 0.2258 0.3226 0.2159 0.4781 0.4984 0.8335 0.3460 Columns 31 through 40 0.0437 0.8043 0.6810 0.8239 0.1325 0.0554 0.8395 0.7892 0.9891 0.0284 Columns 41 through 49 0.7560 0.1650 0.3070 0.3639 0.4263 0.9119 0.7630 0.6616 0.8453