Cody

# Problem 6. Select every other element of a vector

Solution 1859236

Submitted on 27 Jun 2019 by Yannis Ben Ouaghrem
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.6188 0.9233 0.1913 0.8059 0.5136

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.7578 0.2246 0.3447 0.0591 0.1163 0.1466 0.6726 0.8861 0.2624 0.9880 0.2758 0.8631 0.3729 0.1054 0.3418 0.4153 0.3375 0.9297 Columns 19 through 36 0.4805 0.0467 0.1089 0.3660 0.9858 0.8330 0.6921 0.0188 0.7643 0.5421 0.6801 0.2385 0.9691 0.5711 0.9891 0.9420 0.9579 0.2593 Columns 37 through 50 0.7911 0.4085 0.0409 0.9973 0.2134 0.1618 0.6322 0.0506 0.1991 0.8224 0.2931 0.6794 0.6803 0.4626

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!