Cody

# Problem 6. Select every other element of a vector

Solution 1938925

Submitted on 17 Sep 2019 by Lap Nguyen
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))

ans = 0.5562 0.1892 0.9739 0.1938 0.5452

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

ans = Columns 1 through 18 0.8933 0.5196 0.6778 0.8742 0.7371 0.0864 0.7593 0.2843 0.7891 0.7487 0.6552 0.1997 0.4354 0.4472 0.5248 0.5523 0.4592 0.4137 Columns 19 through 36 0.0791 0.4575 0.3057 0.0982 0.6142 0.5558 0.9307 0.3068 0.0085 0.3080 0.4273 0.4754 0.6836 0.8848 0.2395 0.6679 0.3859 0.6794 Columns 37 through 50 0.6245 0.8148 0.3863 0.3148 0.7997 0.1883 0.9890 0.4785 0.9116 0.6121 0.1256 0.4320 0.6735 0.5068

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

ans = 'Aogiegiaaayafrwy'