Cody

# Problem 6. Select every other element of a vector

Solution 1350965

Submitted on 20 Nov 2017 by Robbie Gobrecht
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.4455 0.1022 0.5206 0.2692 0.4132

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.1832 0.9980 0.6488 0.8522 0.7443 0.8430 0.0673 0.8939 0.6499 0.9587 0.6555 0.4355 0.6112 0.8937 0.6484 0.6342 0.3136 0.0383 Columns 19 through 36 0.7789 0.7742 0.3333 0.7638 0.6683 0.4186 0.1299 0.1207 0.4765 0.9318 0.1569 0.5921 0.5023 0.0059 0.3987 0.3075 0.2661 0.1336 Columns 37 through 50 0.2108 0.0062 0.5660 0.3246 0.1255 0.3413 0.9755 0.7862 0.4292 0.8562 0.7512 0.7195 0.7413 0.3708

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'