Cody

# Problem 6. Select every other element of a vector

Solution 277756

Submitted on 10 Jul 2013 by William Fligor
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))

ans = 0.5752 0.2348 0.8212 0.0430 0.6491

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

ans = Columns 1 through 10 0.6477 0.5470 0.7447 0.6868 0.3685 0.7802 0.9294 0.4868 0.4468 0.5085 Columns 11 through 20 0.8176 0.6443 0.8116 0.3507 0.8759 0.6225 0.2077 0.4709 0.8443 0.2259 Columns 21 through 30 0.2277 0.3111 0.4302 0.9049 0.4389 0.2581 0.5949 0.6028 0.2217 0.2967 Columns 31 through 40 0.4242 0.0855 0.8010 0.9289 0.4886 0.2373 0.9631 0.5211 0.4889 0.6791 Columns 41 through 50 0.3674 0.0377 0.9133 0.0987 0.3354 0.1366 0.1068 0.4942 0.7150 0.8909

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))

ans = Aogiegiaaayafrwy