Cody

# Problem 6. Select every other element of a vector

Solution 37573

Submitted on 11 Feb 2012 by Tom
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

### 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.6147 0.4768 0.5721 0.1170 0.7418

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.1872 0.3360 0.1029 0.6414 0.3724 0.8976 Columns 7 through 12 0.4067 0.0516 0.4206 0.5135 0.1858 0.0566 Columns 13 through 18 0.6827 0.9270 0.8700 0.9424 0.4346 0.5245 Columns 19 through 24 0.9585 0.3055 0.8546 0.1568 0.7481 0.4539 Columns 25 through 30 0.2188 0.7315 0.4050 0.5811 0.0504 0.4914 Columns 31 through 36 0.3130 0.0647 0.5791 0.3474 0.0415 0.8663 Columns 37 through 42 0.1714 0.0128 0.8316 0.5071 0.5677 0.3127 Columns 43 through 48 0.6946 0.3969 0.0544 0.3669 0.9144 0.4255 Columns 49 through 50 0.6001 0.7643

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