Cody

# Problem 6. Select every other element of a vector

Solution 668016

Submitted on 8 May 2015 by Clementina Reynolds
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))

y = 0.6501 0.7360 0.1394 0.6565 0.5158

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

y = Columns 1 through 9 0.7469 0.4055 0.6463 0.3984 0.6098 0.4237 0.8735 0.2747 0.9565 Columns 10 through 18 0.8244 0.5990 0.8633 0.8334 0.6533 0.9080 0.0369 0.8117 0.6204 Columns 19 through 27 0.9637 0.2907 0.1078 0.0242 0.2800 0.8830 0.5534 0.6754 0.3568 Columns 28 through 36 0.6336 0.2319 0.9324 0.4570 0.6716 0.4065 0.3243 0.5612 0.7163 Columns 37 through 45 0.5253 0.8208 0.6559 0.3208 0.3767 0.2465 0.0391 0.1798 0.4326 Columns 46 through 50 0.7079 0.4034 0.5811 0.8574 0.2688

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))

y = Aogiegiaaayafrwy