Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 280891

Submitted on 14 Jul 2013 by jdm327
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));

z = 0 1 2 3 4

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

z = 0

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

z = 0

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

z = -4 0 1 2 3

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

z = -4 -3 2 3 4

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

z = Columns 1 through 10 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 Columns 11 through 20 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000 Columns 21 through 30 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 Columns 31 through 40 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 4.6000 4.7000 4.8000 4.9000 Columns 41 through 50 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 Columns 51 through 60 6.0000 6.1000 6.2000 6.3000 6.4000 6.5000 6.6000 6.7000 6.8000 6.9000 Columns 61 through 70 7.0000 7.1000 7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000 Columns 71 through 80 8.0000 8.1000 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000 8.8000 8.9000 Columns 81 through 90 9.0000 9.1000 9.2000 9.3000 9.4000 9.5000 9.6000 9.7000 9.8000 9.9000 Column 91 10.0000

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

z = Columns 1 through 10 -1.0000 0.3486 0.7386 1.5814 2.1922 3.1413 3.5914 4.1336 4.9125 5.7141 Columns 11 through 20 6.3465 7.1777 7.2464 7.4488 7.8539 8.6649 9.4874 9.7760 10.2718 10.6585 Columns 21 through 30 11.5075 11.8178 11.8920 12.7994 12.8189 13.5747 13.5859 13.8162 14.4801 14.6686 Columns 31 through 40 15.0644 15.9227 16.8393 17.1907 17.7462 18.2688 19.2686 19.6464 20.0437 20.7969 Columns 41 through 50 21.6286 22.2480 22.4895 23.1389 24.0855 24.6111 24.7695 25.7144 26.2086 26.4178 Columns 51 through 60 27.1117 27.1183 27.8352 28.2661 28.7606 28.9069 29.5184 29.7538 29.8409 30.5648 Columns 61 through 70 30.6046 31.0069 31.9207 32.6734 33.3290 33.8526 34.6022 34.7160 35.2752 35.9784 Columns 71 through 80 36.0070 36.0500 36.8420 37.5042 37.8740 38.6462 39.5044 40.1501 41.1289 41.9960 Columns 81 through 90 42.7777 43.0319 43.3606 43.5329 44.0876 44.3409 44.9610 45.8822 46.6436 47.5670 Columns 91 through 100 48.5660 48.6223 48.7922 49.6745 50.0600 50.4230 50.7990 51.5610 51.6396 51.7758

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

z = Columns 1 through 10 0.0789 0.7119 1.2794 2.0959 3.0800 3.7526 4.5757 5.2404 6.2352 7.1150 Columns 11 through 20 7.2221 7.6370 7.8853 7.9652 8.3523 8.3705 8.8013 9.5509 10.3796 11.3365 Columns 21 through 30 11.3925 11.7475 12.0846 12.2638 12.3774 13.2589 14.1055 14.9294 15.1600 15.7894 Columns 31 through 40 16.4163 16.7076 17.4561 18.3431 19.0198 19.8226 20.7390 21.1294 21.3012 21.4278 Columns 41 through 50 22.0616 22.5447 23.1612 23.3960 24.3885 24.4346 24.8108 25.5282 25.9590 26.5886