Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1857705

Submitted on 25 Jun 2019
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

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

y = 0

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

y = 0 0 0 0 0

Assertion failed.

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

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

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

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

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

y = Columns 1 through 18 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 Columns 19 through 36 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 Columns 37 through 54 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000 Columns 55 through 72 6.4000 6.5000 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000 7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000 8.0000 8.1000 Columns 73 through 90 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000 8.8000 8.9000 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));

y = Columns 1 through 18 -1.0000 0.6902 1.5360 2.1655 2.3681 3.6981 4.6528 5.2001 5.3732 6.2528 6.6350 7.1778 7.9283 8.2542 8.7753 9.4918 10.3845 10.8330 Columns 19 through 36 10.8949 11.6523 11.8369 12.5391 12.9709 13.8872 13.9091 14.5367 15.1032 16.0898 16.6491 17.2095 17.9489 18.1004 18.7106 19.0051 19.4067 19.9430 Columns 37 through 54 20.4699 20.9422 21.8843 21.9138 22.3852 23.0770 23.2268 23.8799 23.9920 24.2761 25.1577 25.7095 26.3185 27.0964 27.4587 27.9868 28.6786 29.1423 Columns 55 through 72 29.4375 29.7836 30.0381 30.2125 30.8747 31.5595 32.0493 32.9063 33.0663 33.9163 34.2689 34.7141 35.6248 36.0710 36.1621 36.4658 36.8033 37.2946 Columns 73 through 90 38.0776 38.6359 39.6138 40.0535 40.9450 41.3141 42.1411 43.0312 43.2437 44.1480 44.2704 44.4025 45.2206 46.0589 46.2589 46.9527 47.1443 47.8817 Columns 91 through 100 48.2770 49.1063 49.4589 50.3796 51.1051 51.9464 52.2060 52.5773 53.1997 54.1175 tf = logical 0

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

y = Columns 1 through 18 0.4420 0.4866 0.8024 1.4646 1.7280 2.6726 3.4540 3.6791 4.0919 4.1566 4.1767 4.9648 5.5925 6.0030 6.5584 7.2946 7.2965 7.7164 Columns 19 through 36 8.0683 8.5256 8.5397 9.1222 9.8688 10.0498 10.4404 10.5427 10.9957 11.4057 11.7595 12.2189 12.3184 12.8420 12.9510 13.5907 13.9532 14.9423 Columns 37 through 50 15.0703 15.6078 16.1135 16.9847 17.0702 17.1188 17.7479 18.5107 18.8405 19.1418 19.9974 20.0706 20.4466 21.4018