Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 2012086

Submitted on 10 Nov 2019 by kristie moore
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));

i = 5 b = 1 b = 0 b = -1 b = -2 b = -3 tf = logical 1

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

i = 1 b = 1 tf = logical 1

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

i = 5 b = 1 b = 10001 b = 20001 b = 30001 b = 40001 tf = logical 0

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

i = 5 b = 1 b = 0 b = -1 b = -2 b = 9998 tf = logical 0

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

i = 5 b = 1 b = 10001 b = 10000 b = 9999 b = 9998 tf = logical 0

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

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

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

i = 100 b = 1 b = 0 b = -1 b = -2 b = 9998 b = 9997 b = 9996 b = 9995 b = 9994 b = 9993 b = 9992 b = 9991 b = 9990 b = 9989 b = 9988 b = 9987 b = 9986 b = 9985 b = 9984 b = 9983 b = 9982 b = 9981 b = 9980 b = 9979 b = 9978 b = 9977 b = 9976 b = 9975 b = 9974 b = 9973 b = 9972 b = 9971 b = 9970 b = 9969 b = 9968 b = 9967 b = 9966 b = 9965 b = 9964 b = 9963 b = 9962 b = 9961 b = 9960 b = 9959 b = 9958 b = 9957 b = 9956 b = 9955 b = 9954 b = 9953 b = 9952 b = 9951 b = 9950 b = 9949 b = 9948 b = 9947 b = 9946 b = 9945 b = 9944 b = 9943 b = 9942 b = 9941 b = 9940 b = 9939 b = 9938 b = 9937 b = 9936 b = 9935 b = 9934 b = 9933 b = 9932 b = 9931 b = 9930 b = 9929 b = 9928 b = 9927 b = 9926 b = 9925 b = 9924 b = 9923 b = 9922 b = 9921 b = 9920 b = 9919 b = 9918 b = 9917 b = 9916 b = 9915 b = 9914 b = 9913 b = 9912 b = 9911 b = 9910 b = 9909 b = 9908 b = 9907 b = 9906 b = 9905 b = 9904 b = 9903 tf = logical 0

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

i = 50 b = 1 b = 0 b = -1 b = -2 b = -3 b = -4 b = -5 b = -6 b = -7 b = -8 b = -9 b = -10 b = -11 b = -12 b = -13 b = -14 b = -15 b = -16 b = -17 b = -18 b = -19 b = -20 b = -21 b = -22 b = -23 b = -24 b = -25 b = -26 b = -27 b = -28 b = -29 b = -30 b = -31 b = -32 b = -33 b = -34 b = -35 b = -36 b = -37 b = -38 b = -39 b = -40 b = -41 b = -42 b = -43 b = -44 b = -45 b = -46 b = -47 b = -48 tf = logical 1