Cody

# Problem 6. Select every other element of a vector

Solution 1213327

Submitted on 15 Jun 2017 by Donovan Greene
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.7030 0.0122 0.9886 0.7053 0.2973

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.8184 0.6292 0.7593 0.6223 0.9121 0.1692 0.6897 0.9430 0.6061 0.0720 0.8041 0.9955 0.4239 0.0613 0.7919 0.8976 0.3133 0.0563 Columns 19 through 36 0.7813 0.0453 0.8010 0.9167 0.3975 0.9034 0.0836 0.5292 0.2333 0.6686 0.4528 0.7978 0.8901 0.6934 0.8212 0.1048 0.7350 0.4771 Columns 37 through 50 0.4586 0.4857 0.2241 0.8853 0.6283 0.3918 0.7313 0.4199 0.7234 0.5926 0.6963 0.1365 0.5418 0.2412

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'