Cody

# Problem 6. Select every other element of a vector

Solution 203401

Submitted on 13 Feb 2013 by Zackary
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.746313427703679 0.048447339253222 0.603467983830769 0.729709448223228 0.781377051799277

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

y = Columns 1 through 5 0.692531986386519 0.396520792581593 0.780175531491174 0.607865907262946 0.104813241973500 Columns 6 through 10 0.549540107015198 0.890475679184438 0.734341083695970 0.072885299098976 0.798350864113952 Columns 11 through 15 0.683715572408358 0.722724539656766 0.117492852151833 0.328814214756803 0.749131463103519 Columns 16 through 20 0.740032327987778 0.734957541696052 0.866930291751916 0.366436616319199 0.685028472661609 Columns 21 through 25 0.789363943641905 0.206027859505195 0.771933917099107 0.388271631047802 0.228953252023100 Columns 26 through 30 0.484480372398180 0.781931966588002 0.294066333758628 0.530872257027928 0.405315419880591 Columns 31 through 35 0.112283962156027 0.291570317906931 0.964422667215901 0.694752194617940 0.432642326147101 Columns 36 through 40 0.109755050723052 0.187460806421686 0.797830260211597 0.768958264058869 0.272938794123691 Columns 41 through 45 0.673294914108653 0.451739234904736 0.059403296858277 0.772722130862935 0.125332181109180 Columns 46 through 50 0.092352338719202 0.423109385164167 0.722922524692024 0.108817938273045 0.126499865329303

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