Cody

# Problem 6. Select every other element of a vector

Solution 419738

Submitted on 18 Mar 2014 by Wesley Allen
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.4719 0.6473 0.5679 0.9051 0.0733

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.1619 0.2408 0.2719 0.5611 0.3617 0.4153 0.9004 0.2919 0.3777 Columns 10 through 18 0.3075 0.0977 0.3539 0.7566 0.4963 0.1656 0.6827 0.6441 0.9883 Columns 19 through 27 0.1419 0.1596 0.7168 0.2077 0.7916 0.8166 0.7428 0.6250 0.9422 Columns 28 through 36 0.2167 0.1997 0.8727 0.9809 0.3879 0.4956 0.6460 0.1234 0.2080 Columns 37 through 45 0.8343 0.0490 0.2977 0.1672 0.8283 0.0922 0.3048 0.5388 0.9488 Columns 46 through 50 0.7033 0.9550 0.2882 0.2453 0.6999

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