Cody

# Problem 6. Select every other element of a vector

Solution 1947278

Submitted on 24 Sep 2019 by SAMEER SAHAI
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.6970 0.1807 0.2640 0.1722 0.5806

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.1480 0.0139 0.2856 0.7999 0.8578 0.6566 0.7355 0.7085 0.2120 0.3111 0.4349 0.9544 0.5192 0.1225 0.3356 0.5355 0.0414 0.1532 Columns 19 through 36 0.8600 0.8643 0.9468 0.7797 0.3971 0.4523 0.2541 0.6132 0.1874 0.0020 0.0937 0.4504 0.1703 0.4999 0.5652 0.6041 0.8192 0.7767 Columns 37 through 50 0.9511 0.1697 0.6263 0.1412 0.0632 0.8598 0.4268 0.5911 0.0388 0.9961 0.4036 0.1328 0.4018 0.6527

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'