Cody

# Problem 6. Select every other element of a vector

Solution 1350876

Submitted on 20 Nov 2017 by Caleb Ogline
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.5441 0.0698 0.3189 0.0471 0.0163

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

ans = Columns 1 through 17 0.4822 0.2408 0.0723 0.6396 0.8982 0.9117 0.6426 0.4570 0.8174 0.5041 0.4504 0.0593 0.9036 0.4055 0.8866 0.0582 0.8121 Columns 18 through 34 0.0454 0.5789 0.6321 0.6492 0.8614 0.3059 0.3240 0.7341 0.2788 0.6820 0.6607 0.1663 0.0937 0.2545 0.5827 0.6055 0.0358 Columns 35 through 50 0.0371 0.8688 0.2123 0.7268 0.9783 0.9142 0.7364 0.9379 0.7058 0.5154 0.4703 0.7223 0.2119 0.9777 0.4221 0.3005

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'