Cody

# Problem 6. Select every other element of a vector

Solution 706159

Submitted on 24 Jul 2015 by Jonathan Scott
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.8179 0.7437 0.8626 0.8449 0.9283

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.6282 0.5420 0.7845 0.0530 0.0448 0.3617 0.8204 0.9975 0.7047 Columns 10 through 18 0.5675 0.5345 0.0144 0.5230 0.1899 0.8626 0.9899 0.0078 0.5312 Columns 19 through 27 0.5352 0.3946 0.8842 0.7273 0.9152 0.0113 0.1700 0.5256 0.7142 Columns 28 through 36 0.0774 0.5785 0.1676 0.1709 0.1980 0.3771 0.2884 0.8371 0.6629 Columns 37 through 45 0.1379 0.0791 0.5583 0.7097 0.3786 0.1274 0.8816 0.7736 0.4732 Columns 46 through 50 0.1539 0.6565 0.5279 0.4779 0.3056

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!