Cody

# Problem 6. Select every other element of a vector

Solution 1699820

Submitted on 27 Dec 2018 by yuheng su
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 = rand(1,10); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = [] y = 0.4363 y = 0.4363 0.0898 y = 0.4363 0.0898 0.8490 y = 0.4363 0.0898 0.8490 0.9177 y = 0.4363 0.0898 0.8490 0.9177 0.8120

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = [] y = 0.6204 y = 0.6204 0.0591 y = 0.6204 0.0591 0.0532 y = 0.6204 0.0591 0.0532 0.7111 y = 0.6204 0.0591 0.0532 0.7111 0.4742 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 y = 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Column 18 0.3462 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 19 0.3462 0.0423 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 20 0.3462 0.0423 0.4787 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 21 0.3462 0.0423 0.4787 0.4662 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 22 0.3462 0.0423 0.4787 0.4662 0.6132 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 23 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 24 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 25 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 26 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 27 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 28 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 29 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 30 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 31 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 32 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 33 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 34 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 0.5276 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 34 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 0.5276 Column 35 0.2610 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 34 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 0.5276 Columns 35 through 36 0.2610 0.1463 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 34 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 0.5276 Columns 35 through 37 0.2610 0.1463 0.4562 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 34 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 0.5276 Columns 35 through 38 0.2610 0.1463 0.4562 0.1090 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 34 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 0.5276 Columns 35 through 39 0.2610 0.1463 0.4562 0.1090 0.3097 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0.9919 0.5493 0.9207 0.0420 0.2995 Columns 18 through 34 0.3462 0.0423 0.4787 0.4662 0.6132 0.0542 0.8275 0.7384 0.9570 0.2660 0.6492 0.6692 0.6739 0.5620 0.1295 0.7795 0.5276 Columns 35 through 40 0.2610 0.1463 0.4562 0.1090 0.3097 0.4601 y = Columns 1 through 17 0.6204 0.0591 0.0532 0.7111 0.4742 0.9070 0.0914 0.0536 0.8120 0.6653 0.2627 0.9828 0...

3   Pass
x = ['A' 'long' 'time' 'ago' 'in' 'a' 'galaxy' 'far' 'far' 'away']; actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = [] y = 65 y = 65 111 y = 65 111 103 y = 65 111 103 105 y = 65 111 103 105 101 y = 65 111 103 105 101 103 y = 65 111 103 105 101 103 105 y = 65 111 103 105 101 103 105 97 y = 65 111 103 105 101 103 105 97 97 y = 65 111 103 105 101 103 105 97 97 97 y = 65 111 103 105 101 103 105 97 97 97 121 y = 65 111 103 105 101 103 105 97 97 97 121 97 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 121