Cody

# Problem 6. Select every other element of a vector

Solution 352633

Submitted on 16 Nov 2013 by Florian
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.7419 0.9373 0.9592 0.0053 0.1744

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.0294 0.9535 0.5926 0.7187 0.7225 0.5272 0.7301 0.9143 0.6838 0.1976 Columns 11 through 20 0.8538 0.3325 0.9329 0.0978 0.1878 0.0629 0.6129 0.5952 0.0877 0.7939 Columns 21 through 30 0.1806 0.5949 0.6918 0.4454 0.9340 0.7450 0.4352 0.6782 0.9376 0.0683 Columns 31 through 40 0.6303 0.1520 0.3980 0.6623 0.3026 0.3187 0.8749 0.7207 0.6585 0.5990 Columns 41 through 50 0.4508 0.8268 0.0919 0.0894 0.3883 0.2470 0.9480 0.1223 0.0463 0.2392

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