Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 658107

Submitted on 22 Apr 2015 by Catherine Porter
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));

y = 0 1 2 3 4 5

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

y = 0 1

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

y = 0 0 0 0 0 1 tf = 0

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

y = 0 1 2 3 -4 4 tf = 0

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

y = -3 -4 2 3 4 5 tf = 0

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

y = Columns 1 through 9 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 Columns 10 through 18 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 Columns 19 through 27 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 Columns 28 through 36 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 Columns 37 through 45 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 Columns 46 through 54 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000 Columns 55 through 63 6.4000 6.5000 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000 7.2000 Columns 64 through 72 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000 8.0000 8.1000 Columns 73 through 81 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000 8.8000 8.9000 9.0000 Columns 82 through 90 9.1000 9.2000 9.3000 9.4000 9.5000 9.6000 9.7000 9.8000 9.9000 Columns 91 through 92 10.0000 11.0000

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

y = Columns 1 through 9 0.1430 0.8610 1.0260 1.0344 -1.0000 1.8511 2.4477 2.6612 3.0333 Columns 10 through 18 3.0468 3.3409 4.0844 4.9505 5.5720 5.5999 6.0388 6.6027 7.1199 Columns 19 through 27 7.3304 8.2837 8.6024 9.3609 10.0805 10.5211 10.9855 11.7048 12.0103 Columns 28 through 36 12.1444 12.1912 12.8910 13.6789 13.7172 14.0477 14.1108 14.5655 15.4878 Columns 37 through 45 15.7514 16.5598 16.9978 17.0855 17.3627 18.2883 18.5979 19.5168 20.0922 Columns 46 through 54 20.7138 21.3259 21.8743 22.7170 22.9039 22.9155 22.9213 23.0131 23.8265 Columns 55 through 63 24.6874 24.8726 25.5498 25.9289 26.5670 26.8241 27.5273 27.5475 27.6193 Columns 64 through 72 28.3677 29.3444 30.2114 30.6491 31.4454 32.4253 32.4757 32.4821 33.2478 Columns 73 through 81 33.4802 33.5164 33.9597 34.1855 34.3792 34.6315 34.8116 35.5220 36.1671 Columns 82 through 90 36.6719 37.1438 38.1327 38.2339 38.4215 38.8396 39.6353 40.2836 40.4415 Columns 91 through 99 40.9188 41.6612 41.8269 42.5624 42.7957 43.7684 44.3158 44.6207 44.8495 Columns 100 through 101 45.1296 46.1296 tf = 0

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

y = Columns 1 through 9 0.7080 0.8763 1.3610 1.4694 1.8611 2.1496 2.9982 3.3054 3.3819 Columns 10 through 18 4.2538 4.8996 5.2957 5.9557 6.1650 6.3301 7.0821 8.0721 8.5857 Columns 19 through 27 9.3758 10.3532 10.9040 11.2755 11.9639 12.5449 13.3728 14.1663 15.0070 Columns 28 through 36 15.3328 15.4050 16.2145 17.1467 17.9647 18.7171 19.5556 20.5530 21.1163 Columns 37 through 45 21.9550 22.8440 23.7678 23.8412 23.9375 24.5911 24.6728 25.1487 25.7769 Columns 46 through 51 26.0758 26.4349 27.1166 27.3388 27.9765 28.9765

### Community Treasure Hunt

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

Start Hunting!