Cody

# Problem 6. Select every other element of a vector

Solution 2048910

Submitted on 6 Dec 2019 by Martin Thomas
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.2089 0.5443 0.2893 0.3885 0.7445

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

ans = Columns 1 through 18 0.7451 0.1380 0.3219 0.6001 0.8741 0.1529 0.9553 0.4314 0.4446 0.3054 0.8403 0.7386 0.7026 0.6174 0.9213 0.1786 0.7864 0.0103 Columns 19 through 36 0.1400 0.0177 0.8122 0.8704 0.9019 0.5868 0.6306 0.0729 0.5747 0.4889 0.2927 0.2251 0.7423 0.6592 0.8586 0.7049 0.2783 0.4622 Columns 37 through 50 0.5555 0.1385 0.5402 0.9421 0.9803 0.2860 0.6716 0.7829 0.2033 0.1020 0.6006 0.5975 0.8276 0.7299

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'