Cody

# Problem 6. Select every other element of a vector

Solution 1538155

Submitted on 23 May 2018 by Laczi Dániel
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.1700 0.7293 0.5738 0.0980 0.9011

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

ans = Columns 1 through 17 0.1881 0.9165 0.6092 0.1018 0.8362 0.1694 0.1399 0.0396 0.5340 0.4636 0.8310 0.2322 0.1202 0.4897 0.3880 0.1453 0.8780 Columns 18 through 34 0.0394 0.4067 0.6940 0.3224 0.3821 0.6010 0.0945 0.3699 0.5453 0.7396 0.8669 0.2337 0.2849 0.2704 0.3294 0.1170 0.1878 Columns 35 through 50 0.4696 0.2466 0.9171 0.5795 0.7664 0.4912 0.7130 0.3394 0.7457 0.2047 0.0870 0.5627 0.7217 0.3851 0.0803 0.1956

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'