Cody

# Problem 6. Select every other element of a vector

Solution 257179

Submitted on 6 Jun 2013 by Jacob
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 = @(x)x(1:2:end) ans = 0.2332 0.8878 0.9110 0.7941 0.2504

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

ans = @(x)x(1:2:end) ans = Columns 1 through 10 0.2289 0.0721 0.6497 0.0094 0.0479 0.9818 0.0312 0.8651 0.7095 0.6698 Columns 11 through 20 0.1716 0.9671 0.3067 0.3759 0.4975 0.4705 0.6287 0.8062 0.2318 0.8421 Columns 21 through 30 0.8050 0.0729 0.6764 0.2676 0.6174 0.9246 0.0509 0.2559 0.6942 0.5121 Columns 31 through 40 0.8244 0.4077 0.3589 0.8562 0.7609 0.5410 0.4774 0.5684 0.8386 0.9108 Columns 41 through 50 0.0005 0.9609 0.9796 0.4410 0.1196 0.3472 0.1596 0.2519 0.1598 0.1788

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 = @(x)x(1:2:end) ans = Aogiegiaaayafrwy