Cody

# Problem 6. Select every other element of a vector

Solution 850761

Submitted on 15 Mar 2016 by Uttam Landage
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.2541 0.3126 0.5140 0.5728 0.8363

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

y = Columns 1 through 9 0.0930 0.5350 0.1479 0.7387 0.1375 0.5829 0.6117 0.8322 0.8322 Columns 10 through 18 0.3231 0.6956 0.2574 0.9795 0.7012 0.2466 0.9133 0.9150 0.4278 Columns 19 through 27 0.0666 0.2211 0.4170 0.8029 0.8206 0.0537 0.0426 0.4428 0.6511 Columns 28 through 36 0.1734 0.0342 0.2562 0.1535 0.4002 0.2689 0.4591 0.2961 0.2488 Columns 37 through 45 0.0349 0.6674 0.8152 0.2610 0.3747 0.6346 0.8780 0.2055 0.4154 Columns 46 through 50 0.8066 0.8997 0.8709 0.8463 0.3047

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