Cody

# Problem 6. Select every other element of a vector

Solution 555547

Submitted on 11 Jan 2015 by John Nikas
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.0483 0.1284 0.6105 0.7553 0.0118

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

ans = Columns 1 through 9 0.0557 0.7675 0.5789 0.8269 0.2470 0.2869 0.3664 0.9035 0.9397 Columns 10 through 18 0.3795 0.7259 0.8448 0.0824 0.3576 0.3041 0.9263 0.8395 0.2756 Columns 19 through 27 0.3947 0.0670 0.4120 0.6156 0.3177 0.9898 0.6183 0.3057 0.1289 Columns 28 through 36 0.8156 0.1562 0.3947 0.7076 0.4051 0.6337 0.7668 0.5714 0.0628 Columns 37 through 45 0.5734 0.2163 0.4814 0.6885 0.6471 0.3855 0.5145 0.8272 0.5127 Columns 46 through 50 0.3431 0.3327 0.3486 0.0151 0.9952

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