Cody

# Problem 6. Select every other element of a vector

Solution 401002

Submitted on 11 Feb 2014 by Patrick Hudson
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.5199 0.0277 0.4016 0.4494 0.4228

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.0601 0.0602 0.6489 0.6010 0.2442 0.2639 0.1115 0.3867 0.1620 0.7800 Columns 11 through 20 0.5918 0.5108 0.5420 0.1343 0.0331 0.9193 0.5289 0.2569 0.8297 0.3342 Columns 21 through 30 0.3287 0.2622 0.8516 0.7933 0.8495 0.4961 0.9854 0.8662 0.8158 0.5276 Columns 31 through 40 0.7641 0.7504 0.6610 0.4215 0.4779 0.9306 0.3080 0.7114 0.4178 0.8011 Columns 41 through 50 0.4710 0.6536 0.8500 0.7284 0.5674 0.1256 0.3712 0.8425 0.9040 0.6776

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