Cody

# Problem 6. Select every other element of a vector

Solution 1372783

Submitted on 8 Dec 2017 by A. Sawas
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.9233 0.2277 0.9294 0.0866 0.8869

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.5176 0.1916 0.9431 0.9642 0.8669 0.3981 0.9707 0.3586 0.6451 0.8455 0.0740 0.6051 0.4049 0.8773 0.3173 0.1207 0.5183 0.9522 Columns 19 through 36 0.5410 0.1975 0.5389 0.5656 0.8818 0.7965 0.9824 0.2808 0.2861 0.6296 0.9739 0.1706 0.2998 0.7476 0.4956 0.6056 0.7224 0.8132 Columns 37 through 50 0.4869 0.0931 0.7599 0.9226 0.9591 0.5067 0.0636 0.8880 0.9955 0.9580 0.7374 0.4503 0.6234 0.8893

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'