Cody

# Problem 6. Select every other element of a vector

Solution 191371

Submitted on 15 Jan 2013 by Jonathan Campelli
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.6552 0.5931 0.5276 0.2413 0.9140

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.3815 0.2175 0.1884 0.8830 0.3273 0.3667 0.2981 0.2551 0.0887 0.9593 Columns 11 through 20 0.8558 0.4697 0.8517 0.7390 0.1776 0.2145 0.6689 0.4163 0.5063 0.5580 Columns 21 through 30 0.5133 0.4644 0.4747 0.9999 0.3239 0.2679 0.2581 0.6975 0.0332 0.1935 Columns 31 through 40 0.3101 0.0887 0.2724 0.2676 0.9024 0.5975 0.2499 0.6505 0.5247 0.2963 Columns 41 through 50 0.6988 0.0665 0.6136 0.0274 0.9306 0.9343 0.2516 0.1858 0.5327 0.1456

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