Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 226468

Submitted on 2 Apr 2013
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));

d = 0 0 0 ans = 0

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

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

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

d = 0 0 -8 ans = 8

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

d = 7 -5 0 ans = 7

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

d = 1.0e-14 * Columns 1 through 10 -0.0222 0.0222 -0.0222 0.0222 0 0 -0.0222 0 0.0222 0 Columns 11 through 20 0 -0.0444 0.0888 -0.0888 0.0444 0 -0.0444 0.0888 -0.0888 0.0444 Columns 21 through 30 0 0 0 -0.0444 0.0444 0 0 0 -0.0444 0 Columns 31 through 40 0.0888 0 -0.0888 0 0 0.0888 0 -0.0888 0 0.0888 Columns 41 through 50 -0.0888 0 0.0888 -0.0888 0 0.0888 -0.0888 0 0.0888 -0.0888 Columns 51 through 60 0 0.0888 0 -0.0888 0 0 0.0888 0 -0.0888 0 Columns 61 through 70 0 0.0888 0 -0.0888 0 0 0.0888 0 -0.0888 0 Columns 71 through 80 0 0.1776 -0.1776 0 0 0 0.1776 -0.1776 0 0 Columns 81 through 89 0 0.1776 -0.1776 0 0 0 0.1776 -0.1776 0 ans = 1.7764e-15

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

d = Columns 1 through 10 0.0826 -0.0840 -3.8453 7.3931 -3.8992 0.4484 -0.5557 0.4978 -0.5033 0.1850 Columns 11 through 20 0.2571 0.1546 -0.6991 0.8483 -0.1537 -0.2889 -0.0509 0.0109 -0.1404 0.2022 Columns 21 through 30 0.0023 0.3069 -0.0228 -0.1505 -0.2657 0.4330 -0.2788 -0.1821 0.5883 -0.0631 Columns 31 through 40 -0.3258 0.0723 -0.0354 -0.3793 0.0935 0.1697 -0.2404 0.6138 -0.6495 0.0312 Columns 41 through 50 -0.0552 0.0570 0.2080 -0.1246 0.6123 -0.4932 -0.2454 0.7201 0.0749 -0.5409 Columns 51 through 60 -0.3278 0.1469 0.1507 0.1862 -0.3327 0.3406 0.1084 -0.4895 -0.1043 0.1793 Columns 61 through 70 0.0221 0.1054 0.0837 -0.4223 0.1770 0.5385 -0.7718 0.8996 -0.1985 -0.2417 Columns 71 through 80 0.0899 -0.3412 0.2216 0.5042 -0.4163 -0.0257 -0.2895 0.2573 0.1352 0.0551 Columns 81 through 90 -0.2836 -0.0281 0.6205 -0.9502 0.8474 0.0281 -0.1171 -0.6975 0.1632 0.0735 Columns 91 through 98 0.3444 -0.5432 0.5847 -0.6145 0.5470 -0.1596 0.2849 -0.0640 ans = 7.3931

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

Error: Assertion failed.