Cody

# Problem 6. Select every other element of a vector

Solution 583862

Submitted on 17 Feb 2015 by Henry Cervantes
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.3502 0.0629 0.9907 0.7465 0.7884

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.5196 0.3489 0.3871 0.3911 0.9467 0.8331 0.1432 0.8829 0.5807 Columns 10 through 18 0.0310 0.5029 0.3752 0.3295 0.4432 0.7673 0.7227 0.0165 0.8838 Columns 19 through 27 0.6909 0.3259 0.5118 0.0139 0.7693 0.5783 0.4258 0.9139 0.5808 Columns 28 through 36 0.1751 0.0934 0.6725 0.1154 0.0174 0.7340 0.4286 0.7541 0.2487 Columns 37 through 45 0.2098 0.4697 0.8385 0.5524 0.5636 0.2164 0.4997 0.2275 0.1725 Columns 46 through 50 0.8786 0.3343 0.4323 0.2245 0.1544

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