Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 517843

Submitted on 29 Oct 2014
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));

x = 0 1 2 3 4 l1 = 5 y1 = 1 1 1 1

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

x = 0 l1 = 1

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

x = 0 0 0 0 0 l1 = 5 y1 = NaN NaN NaN NaN

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

x = 0 1 2 3 -4 l1 = 5 y1 = 1 1 1 -7

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

x = -3 -4 2 3 4 l1 = 5 y1 = 1 -6 -1 -1

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

Error: Assertion failed.

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

x = Columns 1 through 9 0.9216 1.9187 2.2026 3.1535 -1.0000 4.2853 4.8236 5.6367 6.1617 Columns 10 through 18 6.9742 7.1571 8.0427 8.6240 8.7514 8.8482 9.3458 10.1504 10.3808 Columns 19 through 27 10.4239 11.2193 11.9318 12.4115 12.8358 13.1442 13.9059 14.3353 14.4607 Columns 28 through 36 15.4058 15.5986 16.3603 16.6334 17.5343 17.8172 18.1145 18.5106 18.5982 Columns 37 through 45 18.8227 19.5365 19.6566 20.1306 20.7735 20.9639 21.9167 22.3294 22.7369 Columns 46 through 54 23.3045 23.4351 24.3343 24.4404 25.1642 25.4312 25.6152 26.5712 27.4976 Columns 55 through 63 28.1779 28.8952 29.1444 30.0179 30.1854 30.7515 31.2563 31.3577 31.4950 Columns 64 through 72 31.6655 31.6845 31.7940 32.3477 33.1965 34.1824 34.3893 34.5967 35.2550 Columns 73 through 81 35.3776 36.0225 36.4910 36.9542 37.7860 38.7577 39.1255 39.4259 40.3546 Columns 82 through 90 40.6762 41.6139 42.2535 42.5045 43.3302 43.4886 43.4891 44.2746 45.0427 Columns 91 through 99 45.7983 46.5336 47.1120 47.1717 48.0484 48.3778 49.2837 49.9931 50.2874 Column 100 50.5731 l1 = 100 y1 = Columns 1 through 9 1.0000 0.2847 0.9536 -4.1654 5.3005 0.5398 0.8155 0.5265 0.8149 Columns 10 through 18 0.1835 0.8881 0.5830 0.1277 0.0971 0.4990 0.8070 0.2310 0.0433 Columns 19 through 27 0.7977 0.7145 0.4811 0.4255 0.3093 0.7639 0.4306 0.1258 0.9478 Columns 28 through 36 0.1933 0.7639 0.2739 0.9035 0.2837 0.2981 0.3973 0.0879 0.2251 Columns 37 through 45 0.7159 0.1204 0.4754 0.6448 0.1910 0.9555 0.4139 0.4086 0.5693 Columns 46 through 54 0.1309 0.9017 0.1064 0.7259 0.2678 0.1845 0.9588 0.9290 0.6823 Columns 55 through 63 0.7193 0.2499 0.8760 0.1680 0.5677 0.5063 0.1017 0.1377 0.1710 Columns 64 through 72 0.0190 0.1098 0.5553 0.8513 0.9887 0.2075 0.2080 0.6602 0.1229 Columns 73 through 81 0.6468 0.4698 0.4646 0.8341 0.9745 0.3689 0.3013 0.9314 0.3225 Columns 82 through 90 0.9404 0.6414 0.2518 0.8280 0.1589 0.0005 0.7877 0.7703 0.7578 Columns 91 through 99 0.7374 0.5801 0.0599 0.8793 0.3303 0.9086 0.7114 0.2951 0.2865

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

Error: Assertion failed.

Community Treasure Hunt

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

Start Hunting!