Cody

# Problem 6. Select every other element of a vector

Solution 1270551

Submitted on 18 Sep 2017 by Hassan kamy Berik
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.0349 0.2025 0.5679 0.0317 0.2064

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.6715 0.2761 0.7685 0.9021 0.9550 0.1137 0.3979 0.4720 0.8969 0.4651 0.4508 0.9373 0.8147 0.7727 0.1290 0.7414 0.5831 Columns 18 through 34 0.9968 0.5003 0.9601 0.3665 0.4019 0.4693 0.6088 0.1057 0.9466 0.1454 0.5485 0.6258 0.4424 0.1881 0.9596 0.0512 0.6989 Columns 35 through 50 0.6632 0.7432 0.8089 0.4317 0.3206 0.8632 0.4717 0.8985 0.8310 0.8577 0.0810 0.3041 0.2894 0.7841 0.9233 0.9597

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'