Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 2174364

Submitted on 25 Mar 2020 by Catherine Jones
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
x = [0 1 2 3 4]; assert(isequal(mono_increase(x),true));

a = 1 1 1 1 tf = logical 1

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

a = [] tf = logical 1

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

a = 0 0 0 0 tf = logical 0

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

a = 1 1 1 -7 tf = logical 0

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

a = -1 6 1 1 tf = logical 0

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

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 tf = logical 1

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

a = Columns 1 through 18 0.5696 0.3636 0.2507 -2.5158 4.3533 0.0384 0.9596 0.2375 0.6618 0.1792 0.7562 0.4930 0.2238 0.0916 0.6846 0.3179 0.2251 0.8022 Columns 19 through 36 0.4014 0.9572 0.8082 0.4856 0.4423 0.5059 0.7446 0.6623 0.0841 0.7885 0.5626 0.3263 0.8349 0.7249 0.8287 0.7145 0.1634 0.5499 Columns 37 through 54 0.4450 0.3915 0.3503 0.2080 0.7756 0.7137 0.4829 0.4440 0.8185 0.1374 0.9998 0.8774 0.8261 0.1758 0.1411 0.1840 0.8779 0.1865 Columns 55 through 72 0.9022 0.5846 0.8954 0.4307 0.4059 0.5976 0.6512 0.7945 0.2444 0.3535 0.8456 0.6140 0.9320 0.8906 0.1836 0.9184 0.2870 0.7555 Columns 73 through 90 0.4147 0.0857 0.8755 0.9624 0.9648 0.2855 0.2646 0.6513 0.8217 0.6950 0.3574 0.3810 0.1857 0.4563 0.2862 0.2128 0.5473 0.0621 Columns 91 through 99 0.7693 0.8782 0.6564 0.2748 0.2621 0.8406 0.2634 0.6859 0.1217 tf = logical 0

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

a = Columns 1 through 18 0.2963 0.3433 0.8350 0.6403 0.2016 0.4692 0.0687 0.0546 0.5324 0.4411 0.8802 0.4717 0.5315 0.2447 0.2367 0.7583 0.7781 0.9507 Columns 19 through 36 0.8993 0.7713 0.6492 0.3282 0.1906 0.3003 0.3603 0.3278 0.7318 0.0989 0.0611 0.3675 0.4217 0.1625 0.5569 0.3717 0.6124 0.6941 Columns 37 through 49 0.7778 0.4536 0.8278 0.2391 0.0694 0.1997 0.3441 0.3556 0.3668 0.1435 0.9992 0.3924 0.1552 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!