Cody

# Problem 6. Select every other element of a vector

Solution 397105

Submitted on 5 Feb 2014 by Neha
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.8551 0.5496 0.5220 0.4409 0.2614

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.4597 0.1959 0.7416 0.1071 0.4549 0.9044 0.6038 0.0912 0.5476 0.2359 Columns 11 through 20 0.0790 0.1763 0.9703 0.3318 0.0249 0.9892 0.3969 0.5732 0.1455 0.5011 Columns 21 through 30 0.4064 0.8094 0.6741 0.1821 0.7699 0.4390 0.2168 0.5015 0.3644 0.1228 Columns 31 through 40 0.7366 0.1053 0.4237 0.0988 0.1536 0.1309 0.6631 0.7967 0.0669 0.9087 Columns 41 through 50 0.9898 0.9874 0.6521 0.7978 0.3772 0.0599 0.3834 0.9654 0.9556 0.3972

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