Cody

# Problem 6. Select every other element of a vector

Solution 221525

Submitted on 22 Mar 2013 by Zaka
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 = Columns 1 through 4 0.200450737007957 0.040123698317591 0.139449757816828 0.996763252840420 Column 5 0.307384885979268

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

y = Columns 1 through 4 0.271842610278065 0.735118200045091 0.763850587881877 0.153961100907208 Columns 5 through 8 0.677809430984871 0.322343477668841 0.695924626196233 0.816722324816317 Columns 9 through 12 0.588932251347349 0.372793840899367 0.070159664078100 0.788282372812627 Columns 13 through 16 0.167846321395320 0.643616617599916 0.958059919434953 0.480000215563195 Columns 17 through 20 0.831423444988274 0.413206184723609 0.651877190432052 0.969015643576704 Columns 21 through 24 0.228919140806064 0.938798606856928 0.353697405870984 0.246714954019916 Columns 25 through 28 0.858233193818095 0.502003445531112 0.701283155335371 0.463311698277225 Columns 29 through 32 0.370940029036609 0.586139634895372 0.549913703378061 0.868464032296265 Columns 33 through 36 0.815336004109197 0.039238397258129 0.867227707706437 0.841879268002467 Columns 37 through 40 0.597927190309297 0.466835385822047 0.714656439001355 0.026826670884500 Columns 41 through 44 0.515963897262755 0.866610383810466 0.092451848833600 0.350095356176917 Columns 45 through 48 0.374359594251333 0.200999373198902 0.550640479673898 0.011323765369317 Columns 49 through 50 0.598258676058327 0.171195545109318

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