Cody

# Problem 6. Select every other element of a vector

Solution 33838

Submitted on 8 Feb 2012 by Ninetrees
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.4836 0.6570 0.8491 0.5433 0.4274

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.3564 0.6284 0.1394 0.2821 0.3622 0.2793 Columns 7 through 12 0.0732 0.0003 0.7969 0.7033 0.6154 0.9507 Columns 13 through 18 0.8814 0.8417 0.9334 0.5457 0.3142 0.3645 Columns 19 through 24 0.1604 0.6784 0.2278 0.9389 0.5244 0.1535 Columns 25 through 30 0.5108 0.1893 0.2847 0.1056 0.7994 0.6895 Columns 31 through 36 0.5966 0.0127 0.8659 0.2409 0.2607 0.7610 Columns 37 through 42 0.2987 0.3087 0.8547 0.3778 0.8365 0.8157 Columns 43 through 48 0.6652 0.7697 0.6815 0.3068 0.3351 0.1836 Columns 49 through 50 0.9113 0.0094

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