Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 1029096

Submitted on 24 Oct 2016 by Dan Po
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 = 1 tf = 1 tf = 1 tf = 1 tf = 1 tf = 1 tf = 1 tf = 1

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

tf = 1

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

tf = 1 tf = 0 tf = 0 tf = 0 tf = 0 tf = 0 tf = 0 tf = 0 tf = 0

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

tf = 1 tf = 1 tf = 1 tf = 1 tf = 1 tf = 1 tf = -7 tf = 0

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

tf = -1 tf = 0

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

tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1 tf = 0.1000 tf = 1

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

tf = 0.8385 tf = 1 tf = 0.3895 tf = 1 tf = 0.7759 tf = 1 tf = -3.7392 tf = 0

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

tf = 0.9567 tf = 1 tf = 0.0546 tf = 1 tf = 0.4067 tf = 1 tf = 0.8433 tf = 1 tf = 0.4639 tf = 1 tf = 0.9531 tf = 1 tf = 0.4428 tf = 1 tf = 0.3329 tf = 1 tf = 0.6015 tf = 1 tf = 0.4886 tf = 1 tf = 0.7697 tf = 1 tf = 0.3181 tf = 1 tf = 0.3900 tf = 1 tf = 0.8888 tf = 1 tf = 0.5285 tf = 1 tf = 0.5111 tf = 1 tf = 0.4777 tf = 1 tf = 0.9471 tf = 1 tf = 0.4029 tf = 1 tf = 0.8963 tf = 1 tf = 0.3631 tf = 1 tf = 0.6895 tf = 1 tf = 0.1349 tf = 1 tf = 0.5113 tf = 1 tf = 0.8260 tf = 1 tf = 0.5546 tf = 1 tf = 0.5815 tf = 1 tf = 0.1291 tf = 1 tf = 0.9031 tf = 1 tf = 0.1104 tf = 1 tf = 0.3636 tf = 1 tf = 0.4723 tf = 1 tf = 0.0543 tf = 1 tf = 0.4981 tf = 1 tf = 0.7739 tf = 1 tf = 0.0061 tf = 1 tf = 0.3404 tf = 1 tf = 0.3274 tf = 1 tf = 0.9728 tf = 1 tf = 0.8579 tf = 1 tf = 0.3887 tf = 1 tf = 0.0708 tf = 1 tf = 0.6633 tf = 1 tf = 0.7496 tf = 1 tf = 0.9958 tf = 1 tf = 0.2312 tf = 1 tf = 0.6018 tf = 1 tf = 0.8324 tf = 1 tf = 0.1228 tf = 1

Community Treasure Hunt

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

Start Hunting!