Cody

# Problem 6. Select every other element of a vector

Solution 1101523

Submitted on 10 Jan 2017 by SIVAPRAKASH DANABALASINGAM
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.5219 0.3905 0.5808 0.0546 0.8580

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

ans = Columns 1 through 9 0.7633 0.5066 0.8614 0.2974 0.2446 0.6440 0.7047 0.8256 0.2025 Columns 10 through 18 0.9871 0.5235 0.3758 0.1231 0.0024 0.4044 0.9456 0.0970 0.0429 Columns 19 through 27 0.4269 0.1894 0.9829 0.7631 0.6616 0.8251 0.8904 0.1395 0.8986 Columns 28 through 36 0.1276 0.7356 0.1474 0.3020 0.2263 0.2610 0.5405 0.1405 0.9137 Columns 37 through 45 0.5913 0.1989 0.4809 0.6600 0.1431 0.0260 0.8554 0.8976 0.7229 Columns 46 through 50 0.3634 0.8148 0.2857 0.1424 0.4529

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!