Cody

# Problem 6. Select every other element of a vector

Solution 607790

Submitted on 28 Mar 2015 by meepo iN
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.5081 0.5503 0.1784 0.4407 0.0589 ans = []

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.6748 0.7196 0.6650 0.6698 0.1285 0.5986 0.2564 0.3106 0.6230 Columns 10 through 18 0.8235 0.3586 0.6179 0.5519 0.6674 0.7128 0.9382 0.5335 0.6611 Columns 19 through 27 0.6877 0.0816 0.5396 0.1056 0.5607 0.6801 0.9528 0.7245 0.1397 Columns 28 through 36 0.8668 0.2611 0.3943 0.8001 0.7523 0.1460 0.1323 0.5537 0.9870 Columns 37 through 45 0.6429 0.9079 0.1701 0.6323 0.3469 0.4567 0.3400 0.7701 0.7889 Columns 46 through 50 0.0116 0.4545 0.7874 0.9419 0.9842 ans = []

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 ans = []

### Community Treasure Hunt

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

Start Hunting!