Cody

# Problem 6. Select every other element of a vector

Solution 206053

Submitted on 19 Feb 2013 by Philipp
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.0820 0.2916 0.9380 0.5758 0.2101

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

y = Columns 1 through 10 0.1996 0.6420 0.2613 0.7004 0.3898 0.4618 0.4010 0.3833 0.3586 0.5048 Columns 11 through 20 0.3015 0.5394 0.8186 0.2940 0.1690 0.7912 0.8704 0.1371 0.8510 0.9967 Columns 21 through 30 0.5289 0.3212 0.8001 0.8853 0.2761 0.1408 0.0425 0.6471 0.4984 0.7790 Columns 31 through 40 0.9906 0.1251 0.2696 0.5065 0.6854 0.0255 0.9605 0.1438 0.9931 0.0432 Columns 41 through 50 0.5016 0.5853 0.4485 0.9726 0.2807 0.9180 0.4102 0.9582 0.1970 0.8231

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