Cody

# Problem 6. Select every other element of a vector

Solution 2858162

Submitted on 20 Aug 2020 by Tobias Müller
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))

n = 10 y = 0.7533 0.2548 0.7140 0.2560 0.4144

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

n = 100 y = Columns 1 through 17 0.5051 0.8179 0.7289 0.4272 0.3138 0.4625 0.9148 0.5523 0.5441 0.9427 0.6245 0.8039 0.4458 0.0658 0.5698 0.0510 0.2747 Columns 18 through 34 0.0260 0.4630 0.1253 0.5944 0.2199 0.7611 0.1473 0.2967 0.4726 0.3655 0.6905 0.2482 0.8858 0.3911 0.0209 0.0018 0.4639 Columns 35 through 50 0.5959 0.2309 0.1247 0.5418 0.9506 0.4462 0.9371 0.9936 0.9640 0.1924 0.0027 0.1533 0.9359 0.5083 0.3616 0.6085

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))

n = 31 y = 'Aogiegiaaayafrwy'

### Community Treasure Hunt

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

Start Hunting!