Cody

Problem 10. Determine whether a vector is monotonically increasing

Solution 110113

Submitted on 11 Jul 2012 by M Kyweriga
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));

y = 1 1 1 1 tf = 1

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

y = [] tf = 1

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

y = 0 0 0 0 tf = 0

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

y = 1 1 1 -7 tf = 0

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

y = -1 6 1 1 tf = 0

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

y = Columns 1 through 10 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 11 through 20 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 21 through 30 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 31 through 40 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 41 through 50 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 51 through 60 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 61 through 70 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 71 through 80 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 Columns 81 through 90 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 0.1000 tf = 1

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

y = Columns 1 through 10 0.2550 0.7483 0.9685 -3.7766 5.3763 0.1964 0.2434 0.3679 0.6203 0.4750 Columns 11 through 20 0.9366 0.1165 0.6283 0.0769 0.5795 0.8823 0.4085 0.2674 0.0065 0.0763 Columns 21 through 30 0.9820 0.7859 0.4214 0.3498 0.3259 0.2007 0.2337 0.0015 0.4847 0.0148 Columns 31 through 40 0.3443 0.7345 0.1144 0.9439 0.5688 0.1270 0.7105 0.2148 0.2240 0.4253 Columns 41 through 50 0.4109 0.2671 0.4081 0.5836 0.2497 0.1977 0.5265 0.5677 0.6043 0.4841 Columns 51 through 60 0.0117 0.2327 0.5949 0.1671 0.6067 0.8077 0.1267 0.8549 0.8642 0.5488 Columns 61 through 70 0.8117 0.0273 0.7886 0.5737 0.4627 0.1356 0.2719 0.5044 0.5427 0.4423 Columns 71 through 80 0.0029 0.7779 0.4333 0.6637 0.8585 0.2498 0.2377 0.1597 0.6782 0.3179 Columns 81 through 90 0.0801 0.0141 0.7535 0.4634 0.1791 0.3006 0.8547 0.4631 0.9943 0.5251 Columns 91 through 99 0.2686 0.9471 0.7179 0.1712 0.2733 0.2789 0.4698 0.0180 0.6571 tf = 0

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

y = Columns 1 through 10 0.2728 0.9750 0.3204 0.2701 0.7296 0.8562 0.4759 0.5352 0.1910 0.2878 Columns 11 through 20 0.7945 0.5707 0.4670 0.0126 0.8898 0.0907 0.4123 0.9304 0.9924 0.7180 Columns 21 through 30 0.9666 0.9065 0.6869 0.1028 0.7136 0.2210 0.9753 0.3078 0.5987 0.6481 Columns 31 through 40 0.8542 0.6070 0.7520 0.8959 0.5716 0.8504 0.1562 0.1356 0.0486 0.3433 Columns 41 through 49 0.2903 0.9354 0.9943 0.8489 0.4610 0.9039 0.3012 0.7864 0.9658 tf = 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!