Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 174333

Submitted on 7 Dec 2012 by HaveF
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));

t_x = 1 2 3 4 test_all = 1 1 1 1

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

t_x = Empty matrix: 1-by-0 test_all = Empty matrix: 1-by-0

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

t_x = 0 0 0 0 test_all = 0 0 0 0

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

t_x = 1 2 3 -4 test_all = 1 1 1 -7

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

t_x = -4 2 3 4 test_all = -1 6 1 1

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

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

t_x = Columns 1 through 10 0.5350 0.5498 0.9162 -1.0000 1.7727 1.7898 2.0973 2.3676 3.2348 3.9529 Columns 11 through 20 4.1828 4.4967 5.4757 6.4173 7.1903 8.0214 8.0772 8.2195 8.7238 9.3981 Columns 21 through 30 9.5739 9.9641 10.8825 11.8449 12.6049 12.6779 13.1009 13.2789 13.5389 13.9556 Columns 31 through 40 14.1882 14.3593 14.7940 15.0190 15.9664 16.3439 16.7032 17.6944 18.0203 18.9126 Columns 41 through 50 19.2826 19.2850 20.0459 20.4726 20.6028 21.4548 21.9253 21.9383 22.8773 23.2547 Columns 51 through 60 24.1219 24.9948 25.0165 25.8904 26.7607 26.8679 27.8271 28.2418 29.1590 29.6947 Columns 61 through 70 29.9433 30.7252 31.3261 31.5297 31.9060 31.9714 32.9588 33.4752 34.4209 34.6379 Columns 71 through 80 35.3246 35.7911 36.0470 36.8838 37.1751 37.2912 37.6737 37.8864 38.3950 38.9151 Columns 81 through 90 39.8341 40.7793 41.7296 42.2260 42.8024 43.7926 44.3615 44.9755 45.1255 45.4326 Columns 91 through 99 46.1588 46.7229 46.8686 47.4202 48.0454 48.7289 49.4025 49.6964 49.8385 test_all = Columns 1 through 10 0.1615 0.0148 0.3663 -1.9162 2.7727 0.0171 0.3075 0.2703 0.8672 0.7181 Columns 11 through 20 0.2299 0.3139 0.9790 0.9415 0.7730 0.8311 0.0558 0.1423 0.5043 0.6743 Columns 21 through 30 0.1758 0.3902 0.9185 0.9623 0.7601 0.0730 0.4230 0.1779 0.2600 0.4167 Columns 31 through 40 0.2326 0.1711 0.4347 0.2250 0.9474 0.3775 0.3593 0.9912 0.3259 0.8923 Columns 41 through 50 0.3700 0.0024 0.7609 0.4267 0.1302 0.8520 0.4705 0.0130 0.9390 0.3774 Columns 51 through 60 0.8673 0.8729 0.0217 0.8739 0.8703 0.1072 0.9592 0.4147 0.9172 0.5358 Columns 61 through 70 0.2485 0.7819 0.6009 0.2036 0.3763 0.0654 0.9875 0.5163 0.9458 0.2170 Columns 71 through 80 0.6867 0.4665 0.2558 0.8368 0.2913 0.1161 0.3825 0.2128 0.5086 0.5200 Columns 81 through 90 0.9190 0.9452 0.9503 0.4964 0.5764 0.9901 0.5690 0.6140 0.1500 0.3071 Columns 91 through 99 0.7262 0.5641 0.1457 0.5516 0.6252 0.6835 0.6736 0.2939 0.1421

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

t_x = Columns 1 through 10 1.5339 1.7388 2.0026 2.0934 2.7719 3.7134 3.8666 4.5339 5.3155 6.2167 Columns 11 through 20 6.7259 7.1095 7.8614 8.3147 8.8851 9.2086 9.4770 10.2078 10.2151 10.8634 Columns 21 through 30 11.0679 11.7224 11.9991 12.8577 13.2489 13.9742 14.2567 14.6484 14.9282 15.4939 Columns 31 through 40 15.8709 16.0003 16.1529 16.8603 17.1280 17.9632 18.1339 18.8110 19.0540 19.7014 Columns 41 through 49 20.0356 20.4974 21.2039 21.5605 21.8681 22.6089 23.3929 23.9285 24.1424 test_all = Columns 1 through 10 0.5705 0.2049 0.2638 0.0908 0.6785 0.9415 0.1532 0.6673 0.7816 0.9012 Columns 11 through 20 0.5092 0.3836 0.7518 0.4533 0.5704 0.3234 0.2684 0.7309 0.0073 0.6483 Columns 21 through 30 0.2045 0.6545 0.2767 0.8586 0.3912 0.7252 0.2825 0.3918 0.2797 0.5657 Columns 31 through 40 0.3770 0.1294 0.1526 0.7074 0.2677 0.8351 0.1707 0.6771 0.2430 0.6474 Columns 41 through 49 0.3343 0.4617 0.7065 0.3567 0.3076 0.7408 0.7839 0.5356 0.2139

### Community Treasure Hunt

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

Start Hunting!