Cody

# Problem 10. Determine whether a vector is monotonically increasing

Solution 2050509

Submitted on 8 Dec 2019
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));

o = 0 1 2 3 4 tf = 0 1 2 3 4 tf = logical 1

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

o = 0 tf = 0 tf = logical 1

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

o = 0 0 0 0 0 tf = 0 0 0 0 0 tf = logical 1

Assertion failed.

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

o = 0 1 2 3 -4 tf = -4 0 1 2 3 tf = logical 1

Assertion failed.

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

o = -3 -4 2 3 4 tf = -4 -3 2 3 4 ans = 1×5 logical array 0 0 0 0 0 tf = logical 0

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

o = Columns 1 through 18 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 Columns 19 through 36 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 Columns 37 through 54 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000 Columns 55 through 72 6.4000 6.5000 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000 7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000 8.0000 8.1000 Columns 73 through 90 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000 8.8000 8.9000 9.0000 9.1000 9.2000 9.3000 9.4000 9.5000 9.6000 9.7000 9.8000 9.9000 Column 91 10.0000 tf = Columns 1 through 18 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 Columns 19 through 36 2.8000 2.9000 3.0000 3.1000 3.2000 3.3000 3.4000 3.5000 3.6000 3.7000 3.8000 3.9000 4.0000 4.1000 4.2000 4.3000 4.4000 4.5000 Columns 37 through 54 4.6000 4.7000 4.8000 4.9000 5.0000 5.1000 5.2000 5.3000 5.4000 5.5000 5.6000 5.7000 5.8000 5.9000 6.0000 6.1000 6.2000 6.3000 Columns 55 through 72 6.4000 6.5000 6.6000 6.7000 6.8000 6.9000 7.0000 7.1000 7.2000 7.3000 7.4000 7.5000 7.6000 7.7000 7.8000 7.9000 8.0000 8.1000 Columns 73 through 90 8.2000 8.3000 8.4000 8.5000 8.6000 8.7000 8.8000 8.9000 9.0000 9.1000 9.2000 9.3000 9.4000 9.5000 9.6000 9.7000 9.8000 9.9000 Column 91 10.0000

Matrix dimensions must agree. Error in mono_increase (line 4) if o~tf | x == [0 0 0 0 0] Error in Test6 (line 2) assert(isequal(mono_increase(x),true));

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

o = Columns 1 through 18 0.2260 1.1677 1.8036 2.6896 -1.0000 4.1761 4.2145 4.4766 4.5406 5.5034 5.9950 6.2581 7.0023 7.9360 8.7628 9.2442 9.7170 9.7321 Columns 19 through 36 10.2559 10.4092 11.3304 12.2919 13.0221 13.0689 13.0782 14.0634 14.6936 15.2770 15.3311 16.0366 16.8619 16.9022 17.4214 18.1054 18.5842 19.1498 Columns 37 through 54 19.8300 20.8070 21.2803 21.9702 22.5828 23.3524 23.8392 24.3132 24.5179 25.0477 26.0184 26.9887 27.5568 27.6486 27.9788 28.4878 29.0795 29.3368 Columns 55 through 72 30.3004 30.7822 31.6657 31.9364 32.4105 33.3233 34.0761 34.3292 34.5867 34.9182 35.7155 36.4245 36.4953 37.0878 37.7812 38.5413 39.0495 39.5313 Columns 73 through 90 40.2089 41.0495 41.1515 41.7388 42.6018 43.0373 43.1396 43.7464 44.4443 44.6354 44.9342 45.0969 45.4484 46.2806 46.8335 46.9842 47.8404 48.4834 Columns 91 through 100 48.8102 48.9469 49.3678 50.1185 50.2051 50.8208 51.7761 51.9077 52.4224 53.2482 tf = Columns 1 through 18 -1.0000 0.2260 1.1677 1.8036 2.6896 4.1761 4.2145 4.4766 4.5406 5.5034 5.9950 6.2581 7.0023 7.9360 8.7628 9.2442 9.7170 9.7321 Columns 19 through 36 10.2559 10.4092 11.3304 12.2919 13.0221 13.0689 13.0782 14.0634 14.6936 15.2770 15.3311 16.0366 16.8619 16.9022 17.4214 18.1054 18.5842 19.1498 Columns 37 through 54 19.8300 20.8070 21.2803 21.9702 22.5828 23.3524 23.8392 24.3132 24.5179 25.0477 26.0184 26.9887 27.5568 27.6486 27.9788 28.4878 29.0795 29.3368 Columns 55 through 72 30.3004 30.7822 31.6657 31.9364 32.4105 33.3233 34.0761 34.3292 34.5867 34.9182 35.7155 36.4245 36.4953 37.0878 37.7812 38.5413 39.0495 39.5313 Columns 73 through 90 40.2089 41.0495 41.1515 41.7388 42.6018 43.0373 43.1396 43.7464 44.4443 44.6354 44.9342 45.0969 45.4484 46.2806 46.8335 46.9842 47.8404 48.4834 Columns 91 through 100 48.8102 48.9469 49.3678 50.1185 50.2051 50.8208 51.7761 51.9077 52.4224 53.2482

Matrix dimensions must agree. Error in mono_increase (line 4) if o~tf | x == [0 0 0 0 0] Error in Test7 (line 3) assert(isequal(mono_increase(x),false));

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

o = Columns 1 through 18 0.5948 0.9500 1.8193 2.6870 3.6421 4.6157 4.9203 5.6429 5.9491 6.1778 6.7533 6.7640 7.1648 7.8257 7.9902 8.8279 9.5799 9.6333 Columns 19 through 36 10.0898 11.0564 11.5828 12.1194 13.0522 13.4389 13.6757 14.3754 14.8792 15.1905 15.3627 15.9681 16.7613 17.6041 17.6808 18.1390 18.9270 19.8832 Columns 37 through 50 20.6852 21.6732 22.5877 22.9164 22.9380 23.7878 24.5381 25.4667 26.1090 27.0908 27.0935 27.9020 28.3020 28.5701 tf = Columns 1 through 18 0.5948 0.9500 1.8193 2.6870 3.6421 4.6157 4.9203 5.6429 5.9491 6.1778 6.7533 6.7640 7.1648 7.8257 7.9902 8.8279 9.5799 9.6333 Columns 19 through 36 10.0898 11.0564 11.5828 12.1194 13.0522 13.4389 13.6757 14.3754 14.8792 15.1905 15.3627 15.9681 16.7613 17.6041 17.6808 18.1390 18.9270 19.8832 Columns 37 through 50 20.6852 21.6732 22.5877 22.9164 22.9380 23.7878 24.5381 25.4667 26.1090 27.0908 27.0935 27.9020 28.3020 28.5701

Matrix dimensions must agree. Error in mono_increase (line 4) if o~tf | x == [0 0 0 0 0] Error in Test8 (line 2) assert(isequal(mono_increase(x),true));