Cody

# Problem 6. Select every other element of a vector

Solution 1783703

Submitted on 11 Apr 2019 by Victoria Brooks
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))

x3 = 0.7423 x3 = 0.7423 0.2519 x3 = 0.7423 0.2519 0.2820 x3 = 0.7423 0.2519 0.2820 0.8937 x3 = 0.7423 0.2519 0.2820 0.8937 0.5536

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

x3 = 0.7844 x3 = 0.7844 0.2240 x3 = 0.7844 0.2240 0.4423 x3 = 0.7844 0.2240 0.4423 0.0923 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 x3 = 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Column 19 0.4574 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 20 0.4574 0.8367 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 21 0.4574 0.8367 0.0147 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 22 0.4574 0.8367 0.0147 0.0959 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 23 0.4574 0.8367 0.0147 0.0959 0.7246 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 24 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 25 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 26 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 27 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 28 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 29 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 30 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 31 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 32 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 33 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 34 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 0.8201 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 35 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 0.8201 0.6663 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 36 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 0.8201 0.6663 0.4266 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 36 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 0.8201 0.6663 0.4266 Column 37 0.2460 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 36 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 0.8201 0.6663 0.4266 Columns 37 through 38 0.2460 0.2493 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 36 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 0.8201 0.6663 0.4266 Columns 37 through 39 0.2460 0.2493 0.1633 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 36 0.4574 0.8367 0.0147 0.0959 0.7246 0.0355 0.0544 0.0208 0.6571 0.9299 0.8463 0.2690 0.6953 0.4161 0.1368 0.8201 0.6663 0.4266 Columns 37 through 40 0.2460 0.2493 0.1633 0.2249 x3 = Columns 1 through 18 0.7844 0.2240 0.4423 0.0923 0.8196 0.8914 0.0008 0.8540 0.6063 0.2539 0.6360 0.3852 0.0662 0.0538 0.9361 0.0054 0.7726 0.7444 Columns 19 through 3...

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))

x3 = 65 x3 = 65 111 x3 = 65 111 103 x3 = 65 111 103 105 x3 = 65 111 103 105 101 x3 = 65 111 103 105 101 103 x3 = 65 111 103 105 101 103 105 x3 = 65 111 103 105 101 103 105 97 x3 = 65 111 103 105 101 103 105 97 97 x3 = 65 111 103 105 101 103 105 97 97 97 x3 = 65 111 103 105 101 103 105 97 97 97 121 x3 = 65 111 103 105 101 103 105 97 97 97 121 97 x3 = 65 111 103 105 101 103 105 97 97 97 121 97 102 x3 = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 x3 = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 x3 = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 121