Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1910827

Submitted on 24 Aug 2019 by Sivakumar Selvam
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 = 1 2 3 4 x = 0 1 2 3 tf = logical 1

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

y = 0 tf = logical 1

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

y = 0 0 0 0 x = 0 0 0 0 tf = logical 0

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

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

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

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

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

y = Columns 1 through 18 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 2.8000 Columns 19 through 36 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 4.6000 Columns 37 through 54 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 6.4000 Columns 55 through 72 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 8.2000 Columns 73 through 90 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 10.0000 x = 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 tf = logical 1

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

y = Columns 1 through 18 0.9526 1.1797 1.8136 -1.0000 3.1236 3.5704 4.5448 5.0605 5.5105 5.8300 6.4184 7.0472 7.6748 8.6001 8.8846 9.3609 10.2690 11.1807 Columns 19 through 36 11.8843 12.2294 12.8527 13.3522 14.2751 14.7414 15.6369 15.7187 16.2711 17.2708 17.8996 18.8972 19.3109 19.5360 19.6694 19.7293 20.7032 21.6802 Columns 37 through 54 22.4595 23.0385 23.8369 23.9582 24.9501 25.8383 26.6672 27.4289 27.9679 28.5959 28.9953 29.5767 29.7764 29.8071 30.0836 30.9538 31.7617 32.3511 Columns 55 through 72 33.2204 34.1295 34.5982 34.8774 35.0731 35.4443 35.7370 36.4670 36.8733 37.2768 37.3720 38.3121 39.1434 39.9206 40.5427 40.6339 40.8317 41.3490 Columns 73 through 90 41.3766 42.1106 42.5663 43.1554 43.2495 43.8935 44.4542 45.4309 45.8145 46.5127 47.3158 47.4945 48.0124 48.2928 48.3157 48.4814 49.2928 50.2115 Columns 91 through 99 50.2276 50.6117 51.4307 51.5849 52.0140 52.7570 53.3661 54.1125 54.2325 x = Columns 1 through 18 0.1773 0.9526 1.1797 1.8136 -1.0000 3.1236 3.5704 4.5448 5.0605 5.5105 5.8300 6.4184 7.0472 7.6748 8.6001 8.8846 9.3609 10.2690 Columns 19 through 36 11.1807 11.8843 12.2294 12.8527 13.3522 14.2751 14.7414 15.6369 15.7187 16.2711 17.2708 17.8996 18.8972 19.3109 19.5360 19.6694 19.7293 20.7032 Columns 37 through 54 21.6802 22.4595 23.0385 23.8369 23.9582 24.9501 25.8383 26.6672 27.4289 27.9679 28.5959 28.9953 29.5767 29.7764 29.8071 30.0836 30.9538 31.7617 Columns 55 through 72 32.3511 33.2204 34.1295 34.5982 34.8774 35.0731 35.4443 35.7370 36.4670 36.8733 37.2768 37.3720 38.3121 39.1434 39.9206 40.5427 40.6339 40.8317 Columns 73 through 90 41.3490 41.3766 42.1106 42.5663 43.1554 43.2495 43.8935 44.4542 45.4309 45.8145 46.5127 47.3158 47.4945 48.0124 48.2928 48.3157 48.4814 49.2928 Columns 91 through 99 50.2115 50.2276 50.6117 51.4307 51.5849 52.0140 52.7570 53.3661 54.1125 tf = logical 0

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

y = Columns 1 through 18 1.2927 1.8187 2.0144 2.5402 3.4827 4.3357 5.2896 5.4999 6.2741 7.1274 7.4688 7.7574 8.3455 8.6987 8.9659 9.6220 9.7686 10.1437 Columns 19 through 36 10.8709 11.4511 12.0897 12.9289 12.9310 13.9104 13.9636 13.9954 14.3565 14.9173 15.3065 16.2301 16.7110 17.2619 17.3621 17.8380 18.1004 18.3927 Columns 37 through 49 19.0844 19.7773 20.1289 20.2515 20.8611 21.2646 21.6128 22.1936 22.4465 23.0690 23.8499 23.9692 24.6438 x = Columns 1 through 18 0.7529 1.2927 1.8187 2.0144 2.5402 3.4827 4.3357 5.2896 5.4999 6.2741 7.1274 7.4688 7.7574 8.3455 8.6987 8.9659 9.6220 9.7686 Columns 19 through 36 10.1437 10.8709 11.4511 12.0897 12.9289 12.9310 13.9104 13.9636 13.9954 14.3565 14.9173 15.3065 16.2301 16.7110 17.2619 17.3621 17.8380 18.1004 Columns 37 through 49 18.3927 19.0844 19.7773 20.1289 20.2515 20.8611 21.2646 21.6128 22.1936 22.4465 23.0690 23.8499 23.9692 tf = logical 1