Cody

# Problem 6. Select every other element of a vector

Solution 204056

Submitted on 14 Feb 2013 by Frank
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.4574 0.5181 0.6377 0.2407 0.2891

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

y = Columns 1 through 10 0.6951 0.2548 0.6678 0.3445 0.6753 0.6022 0.9160 0.4624 0.4609 0.3225 Columns 11 through 20 0.4714 0.1759 0.4735 0.3411 0.1917 0.2428 0.2691 0.1887 0.0911 0.6834 Columns 21 through 30 0.4257 0.6476 0.6358 0.2089 0.2362 0.6073 0.4587 0.7703 0.6620 0.8419 Columns 31 through 40 0.2564 0.5822 0.8699 0.3181 0.9398 0.4795 0.5447 0.5439 0.5225 0.2187 Columns 41 through 50 0.1097 0.4046 0.3658 0.6279 0.9329 0.1920 0.6963 0.5254 0.8611 0.3935

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