Cody

# Problem 6. Select every other element of a vector

Solution 1093870

Submitted on 29 Dec 2016 by KHOGULAN THANGAIAH
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.5077 0.1951 0.2026 0.6637 0.2502

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.4035 0.7378 0.6047 0.5766 0.7662 0.1483 0.5243 0.9658 0.1751 Columns 10 through 18 0.0729 0.2990 0.2153 0.1056 0.2888 0.2338 0.0327 0.3230 0.3620 Columns 19 through 27 0.3227 0.5183 0.7351 0.3482 0.1979 0.0167 0.2130 0.6319 0.2615 Columns 28 through 36 0.7418 0.8595 0.2304 0.4246 0.7072 0.0989 0.1743 0.1326 0.9355 Columns 37 through 45 0.4871 0.2053 0.1957 0.7571 0.3510 0.8834 0.1253 0.1474 0.9513 Columns 46 through 50 0.4645 0.7198 0.1225 0.1142 0.6539

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