Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 3180876

Submitted on 12 Oct 2020 by Roman Kovalevskiy
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));

d = 1 1 1 1 tf = logical 1

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

d = 1 1 1 -7 tf = logical 0

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

d = -1 6 1 1 tf = logical 0

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

d = Columns 1 through 17 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 18 through 34 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 35 through 51 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 52 through 68 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 69 through 85 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 86 through 90 0.1000 0.1000 0.1000 0.1000 0.1000 tf = logical 1

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

d = Columns 1 through 17 0.8201 0.5151 0.5005 -3.3858 4.1202 0.5083 0.3778 0.5467 0.5443 0.6170 0.7681 0.5550 0.9115 0.8390 0.2272 0.4977 0.0229 Columns 18 through 34 0.9443 0.2688 0.8972 0.7350 0.9704 0.4488 0.6533 0.0110 0.3658 0.7835 0.8178 0.5908 0.3726 0.8636 0.7812 0.2268 0.3732 Columns 35 through 51 0.3438 0.4709 0.5435 0.6552 0.6675 0.6864 0.6442 0.9951 0.6191 0.9605 0.2085 0.0069 0.0870 0.1470 0.0885 0.7738 0.2075 Columns 52 through 68 0.6084 0.1744 0.7031 0.1058 0.0346 0.5509 0.0344 0.3142 0.6222 0.6555 0.6271 0.7814 0.1963 0.4579 0.3813 0.7795 0.6080 Columns 69 through 85 0.9014 0.4990 0.2007 0.4796 0.5834 0.1882 0.1213 0.9987 0.8786 0.5988 0.6527 0.7781 0.3722 0.9008 0.1421 0.5209 0.8210 Columns 86 through 99 0.7671 0.9961 0.6727 0.7461 0.7706 0.8208 0.2658 0.6056 0.1172 0.0764 0.8337 0.5116 0.7836 0.9846 tf = logical 0

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

d = Columns 1 through 17 0.7481 0.7585 0.5407 0.6523 0.3965 0.3500 0.9752 0.8948 0.4985 0.9534 0.9891 0.0848 0.5820 0.9823 0.9719 0.4115 0.2536 Columns 18 through 34 0.9883 0.7006 0.6472 0.5694 0.9269 0.7382 0.6701 0.0290 0.3003 0.3893 0.1064 0.1443 0.0828 0.0487 0.5600 0.8667 0.0675 Columns 35 through 49 0.5612 0.4907 0.0922 0.0710 0.8712 0.7761 0.3286 0.2479 0.2549 0.1552 0.2024 0.9274 0.3955 0.3083 0.7281 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!