Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 787182

Submitted on 2 Dec 2015 by Kevin Lamb
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));

x1 = 0 1 2 3 4 Inf x2 = -Inf 0 1 2 3 4

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

x1 = 0 Inf x2 = -Inf 0

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

x1 = 0 0 0 0 0 Inf x2 = -Inf 0 0 0 0 0

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

x1 = 0 1 2 3 -4 Inf x2 = -Inf 0 1 2 3 -4

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

x1 = -3 -4 2 3 4 Inf x2 = -Inf -3 -4 2 3 4

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

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

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

x1 = Columns 1 through 9 0.9112 1.8762 2.0872 2.7987 -1.0000 4.1996 4.9818 5.4019 5.9575 Columns 10 through 18 6.8870 7.6436 8.0815 8.8853 8.9249 9.1608 9.4381 9.9514 10.5605 Columns 19 through 27 11.1633 11.4603 12.1982 12.5030 13.2680 13.5098 13.5859 14.2497 14.5095 Columns 28 through 36 14.5246 14.9257 15.6801 16.2011 16.8993 17.7172 18.5066 19.0670 19.1587 Columns 37 through 45 19.4791 20.3058 20.6355 21.3600 21.8644 22.4604 22.5144 23.1297 23.3489 Columns 46 through 54 23.7056 24.0012 24.7187 25.2092 25.3660 25.8049 25.9155 26.3923 27.0551 Columns 55 through 63 27.4475 28.2768 28.8539 29.0463 29.2051 30.1453 30.2543 30.5577 31.1665 Columns 64 through 72 31.6883 31.7660 32.3587 32.5632 33.4808 33.9014 34.7456 35.0760 35.2181 Columns 73 through 81 35.7568 35.9573 36.0718 36.1964 36.5278 37.1810 37.3472 38.0982 38.7826 Columns 82 through 90 39.4399 39.8025 40.0474 40.3094 40.5408 40.5726 40.7259 40.9225 41.2305 Columns 91 through 99 41.3963 42.3220 42.7423 43.1045 43.8213 44.6885 44.7576 45.3004 46.2886 Columns 100 through 101 46.6762 Inf x2 = Columns 1 through 9 -Inf 0.9112 1.8762 2.0872 2.7987 -1.0000 4.1996 4.9818 5.4019 Columns 10 through 18 5.9575 6.8870 7.6436 8.0815 8.8853 8.9249 9.1608 9.4381 9.9514 Columns 19 through 27 10.5605 11.1633 11.4603 12.1982 12.5030 13.2680 13.5098 13.5859 14.2497 Columns 28 through 36 14.5095 14.5246 14.9257 15.6801 16.2011 16.8993 17.7172 18.5066 19.0670 Columns 37 through 45 19.1587 19.4791 20.3058 20.6355 21.3600 21.8644 22.4604 22.5144 23.1297 Columns 46 through 54 23.3489 23.7056 24.0012 24.7187 25.2092 25.3660 25.8049 25.9155 26.3923 Columns 55 through 63 27.0551 27.4475 28.2768 28.8539 29.0463 29.2051 30.1453 30.2543 30.5577 Columns 64 through 72 31.1665 31.6883 31.7660 32.3587 32.5632 33.4808 33.9014 34.7456 35.0760 Columns 73 through 81 35.2181 35.7568 35.9573 36.0718 36.1964 36.5278 37.1810 37.3472 38.0982 Columns 82 through 90 38.7826 39.4399 39.8025 40.0474 40.3094 40.5408 40.5726 40.7259 40.9225 Columns 91 through 99 41.2305 41.3963 42.3220 42.7423 43.1045 43.8213 44.6885 44.7576 45.3004 Columns 100 through 101 46.2886 46.6762

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

x1 = Columns 1 through 9 0.4526 0.7095 1.0355 1.9163 2.5225 3.0970 3.1871 3.3181 4.1601 Columns 10 through 18 4.6343 5.6251 6.3454 7.2027 7.3735 8.0869 8.7144 9.1281 9.2758 Columns 19 through 27 9.8167 9.9123 10.9112 11.5848 11.7744 12.5035 12.7643 13.5663 14.2098 Columns 28 through 36 15.0334 15.0963 15.9374 16.8757 17.4768 18.2651 18.8625 19.0898 19.4529 Columns 37 through 45 19.9885 20.6387 21.6233 22.3931 22.7730 23.3741 23.9812 24.6779 25.0672 Columns 46 through 51 25.7819 26.4304 27.3098 28.0032 28.2743 Inf x2 = Columns 1 through 9 -Inf 0.4526 0.7095 1.0355 1.9163 2.5225 3.0970 3.1871 3.3181 Columns 10 through 18 4.1601 4.6343 5.6251 6.3454 7.2027 7.3735 8.0869 8.7144 9.1281 Columns 19 through 27 9.2758 9.8167 9.9123 10.9112 11.5848 11.7744 12.5035 12.7643 13.5663 Columns 28 through 36 14.2098 15.0334 15.0963 15.9374 16.8757 17.4768 18.2651 18.8625 19.0898 Columns 37 through 45 19.4529 19.9885 20.6387 21.6233 22.3931 22.7730 23.3741 23.9812 24.6779 Columns 46 through 51 25.0672 25.7819 26.4304 27.3098 28.0032 28.2743