Cody

# Problem 6. Select every other element of a vector

Solution 94569

Submitted on 1 Jun 2012 by George
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.0012 0.7372 0.9961 0.8516 0.1842

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

y = Columns 1 through 6 0.1815 0.6793 0.4808 0.3781 0.8977 0.7098 Columns 7 through 12 0.9701 0.4010 0.1663 0.1680 0.4453 0.9728 Columns 13 through 18 0.9624 0.9049 0.9317 0.1613 0.4638 0.8622 Columns 19 through 24 0.8900 0.3865 0.3420 0.8485 0.9027 0.1764 Columns 25 through 30 0.9941 0.4481 0.0550 0.4473 0.1154 0.9494 Columns 31 through 36 0.0900 0.4760 0.1950 0.6883 0.4657 0.6807 Columns 37 through 42 0.0562 0.2338 0.1417 0.5372 0.4092 0.4411 Columns 43 through 48 0.3141 0.2462 0.0562 0.5862 0.3938 0.4968 Columns 49 through 50 0.4290 0.6326

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!