Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 2545278

Submitted on 14 Jun 2020 by Li Kehan Li
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));

tf = logical 0 a = 1 1 1 1 b = 1 2 3 4 tf = logical 1

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

tf = logical 0 a = 1 1 1 -7 b = 1 2 3 4

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

tf = logical 0 a = -1 6 1 1 b = 1 2 3 4

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

tf = logical 0 a = 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 b = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 60 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Columns 61 through 90 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 tf = logical 1

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

tf = logical 0 a = Columns 1 through 18 0.0461 0.1840 0.8865 -3.1050 4.2613 0.5650 0.0148 0.8796 0.8865 0.1629 0.8499 0.5579 0.3940 0.5500 0.1229 0.7359 0.0032 0.8595 Columns 19 through 36 0.9256 0.8911 0.2305 0.0436 0.0506 0.1555 0.1285 0.7069 0.6304 0.9800 0.9099 0.7668 0.4445 0.4501 0.9712 0.5725 0.6954 0.0714 Columns 37 through 54 0.2532 0.6693 0.4344 0.8596 0.1585 0.3236 0.6072 0.9969 0.2346 0.1419 0.8584 0.8556 0.4717 0.5017 0.0414 0.4735 0.2385 0.3110 Columns 55 through 72 0.5172 0.6201 0.1271 0.5820 0.8645 0.7737 0.8543 0.3597 0.1970 0.3087 0.4452 0.5640 0.1279 0.1958 0.8200 0.5373 0.8296 0.0628 Columns 73 through 90 0.0146 0.3612 0.8392 0.5471 0.1978 0.5008 0.0758 0.6219 0.5051 0.0820 0.7341 0.7942 0.0039 0.0439 0.8739 0.3132 0.8445 0.0073 Columns 91 through 99 0.9022 0.3782 0.1336 0.8701 0.3541 0.1925 0.9088 0.5205 0.3481 b = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 60 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Columns 61 through 90 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 Columns 91 through 99 91 92 93 94 95 96 97 98 99

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

tf = logical 0 a = Columns 1 through 18 0.4472 0.0180 0.1589 0.8616 0.9747 0.2282 0.2230 0.5068 0.8218 0.5776 0.8285 0.4813 0.0628 0.8266 0.3357 0.2223 0.3310 0.9484 Columns 19 through 36 0.5550 0.9803 0.1461 0.4465 0.1572 0.6896 0.5646 0.3166 0.3162 0.2860 0.0524 0.5938 0.1561 0.2973 0.6164 0.3048 0.9087 0.0017 Columns 37 through 49 0.2393 0.3621 0.3809 0.5904 0.2495 0.0547 0.5627 0.6061 0.0676 0.9111 0.8599 0.2308 0.3769 b = Columns 1 through 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Columns 31 through 49 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 tf = logical 1

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!