Cody

# Problem 6. Select every other element of a vector

Solution 1094173

Submitted on 29 Dec 2016 by Nazmi Azim Azmi
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.5760 0.6621 0.6280 0.3235 0.2483

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

ans = Columns 1 through 9 0.2183 0.7386 0.2996 0.0746 0.9093 0.2866 0.4346 0.7025 0.9844 Columns 10 through 18 0.0437 0.5535 0.5917 0.8206 0.4275 0.2539 0.4870 0.4999 0.7514 Columns 19 through 27 0.8606 0.0050 0.5537 0.4360 0.5218 0.8995 0.7624 0.8407 0.2510 Columns 28 through 36 0.8488 0.6076 0.5421 0.6711 0.7017 0.1044 0.1506 0.5832 0.3944 Columns 37 through 45 0.2912 0.0254 0.1390 0.8919 0.4071 0.6810 0.4292 0.3352 0.3390 Columns 46 through 50 0.8535 0.5725 0.8162 0.4349 0.1829

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