Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 1396923

Submitted on 29 Dec 2017 by claus becker
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));

Delta = 1 1 1 1 Q = 1×4 logical array 0 0 0 0 Summmm = 0 tf = logical 1

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

Delta = [] Q = 0×0 empty logical array Summmm = 0 tf = logical 1

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

Delta = 0 0 0 0 Q = 1×4 logical array 1 1 1 1 Summmm = 4

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

Delta = 1 1 1 -7 Q = 1×4 logical array 0 0 0 1 Summmm = 1

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

Delta = -1 6 1 1 Q = 1×4 logical array 1 0 0 0 Summmm = 1

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

Delta = Columns 1 through 18 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 19 through 36 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 37 through 54 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 55 through 72 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 73 through 90 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Q = 1×90 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Summmm = 0 tf = logical 1

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

Delta = Columns 1 through 18 0.0953 0.4437 0.3372 -2.0687 2.5246 0.4443 0.7988 0.0032 0.4213 0.2394 0.5210 0.5419 0.6058 0.9812 0.9820 0.5797 0.9311 0.6886 Columns 19 through 36 0.8385 0.0935 0.3094 0.8925 0.4058 0.1127 0.4409 0.3029 0.9320 0.2749 0.9521 0.0926 0.9771 0.1999 0.6384 0.8343 0.8461 0.5831 Columns 37 through 54 0.3526 0.2715 0.8703 0.3010 0.9934 0.7907 0.2517 0.3535 0.7855 0.5910 0.1261 0.4048 0.5059 0.8154 0.6728 0.6270 0.9235 0.6877 Columns 55 through 72 0.9022 0.7952 0.1295 0.3804 0.1015 0.0176 0.1755 0.5870 0.8805 0.4012 0.0324 0.0687 0.8345 0.3061 0.5840 0.1439 0.2824 0.1659 Columns 73 through 90 0.9084 0.0903 0.1613 0.5770 0.6326 0.7946 0.1840 0.9021 0.7745 0.5060 0.4665 0.3075 0.6146 0.8024 0.9804 0.0018 0.8250 0.8096 Columns 91 through 99 0.4333 0.3697 0.0081 0.8981 0.7672 0.0641 0.1467 0.4032 0.4132 Q = 1×99 logical array Columns 1 through 45 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 91 through 99 0 0 0 0 0 0 0 0 0 Summmm = 1

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

Delta = Columns 1 through 18 0.2864 0.6407 0.8354 0.9860 0.4473 0.6446 0.1802 0.5023 0.1175 0.8779 0.8990 0.5366 0.8086 0.0339 0.2691 0.8035 0.7099 0.4012 Columns 19 through 36 0.0938 0.3517 0.8026 0.8611 0.4654 0.8951 0.4489 0.9997 0.3495 0.6298 0.0720 0.3878 0.8546 0.7594 0.8190 0.9907 0.6358 0.5034 Columns 37 through 49 0.3790 0.8453 0.6338 0.5034 0.9634 0.4570 0.8643 0.6510 0.9735 0.4069 0.2811 0.5228 0.5387 Q = 1×49 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 49 0 0 0 0 Summmm = 0 tf = logical 1

### Community Treasure Hunt

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

Start Hunting!