Cody

# Problem 6. Select every other element of a vector

Solution 1936360

Submitted on 15 Sep 2019 by Julian Lippmann
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.6530 0.3488 0.6225 0.8261 0.0819

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.7155 0.0242 0.7015 0.3476 0.3887 0.0089 0.6862 0.6021 0.6665 0.9060 0.6003 0.3031 0.9429 0.0394 0.1626 0.8617 0.9139 0.3511 Columns 19 through 36 0.1222 0.7450 0.5944 0.7384 0.2145 0.9331 0.2379 0.2188 0.1867 0.3463 0.0770 0.6801 0.0256 0.1256 0.4072 0.2784 0.7230 0.8629 Columns 37 through 50 0.0522 0.9088 0.6806 0.8993 0.3135 0.2669 0.7941 0.1614 0.1188 0.9563 0.0574 0.5458 0.8666 0.7686

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'