Cody

# Problem 6. Select every other element of a vector

Solution 187677

Submitted on 7 Jan 2013 by Roger
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.7094 0.2760 0.6551 0.1190 0.9597

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

ans = Columns 1 through 10 0.5853 0.7513 0.5060 0.8909 0.5472 0.1493 0.8407 0.8143 0.9293 0.1966 Columns 11 through 20 0.6160 0.3517 0.5853 0.9172 0.7572 0.3804 0.0759 0.5308 0.9340 0.5688 Columns 21 through 30 0.0119 0.1622 0.3112 0.1656 0.2630 0.6892 0.4505 0.2290 0.1524 0.5383 Columns 31 through 40 0.0782 0.1067 0.0046 0.8173 0.0844 0.2599 0.4314 0.1818 0.1455 0.8693 Columns 41 through 50 0.5499 0.8530 0.3510 0.4018 0.2399 0.1839 0.4173 0.9027 0.4909 0.3377

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