Cody

# Problem 6. Select every other element of a vector

Solution 2281320

Submitted on 14 May 2020 by Ramesh Kumar V
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))

y = 0.9720 0.5831 0.7872 0.2778 0.8984

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

y = Columns 1 through 18 0.9704 0.5303 0.0772 0.1352 0.5956 0.1033 0.0644 0.1324 0.0057 0.1366 0.1712 0.2708 0.6477 0.3060 0.4669 0.5882 0.6546 0.2365 Columns 19 through 36 0.8057 0.9455 0.8616 0.7377 0.8159 0.6579 0.5511 0.5765 0.8196 0.3555 0.5553 0.2538 0.9635 0.5904 0.7942 0.7761 0.4315 0.9260 Columns 37 through 50 0.6714 0.7334 0.4118 0.9445 0.4231 0.4750 0.1953 0.3928 0.9934 0.3017 0.2960 0.4793 0.9630 0.1985

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

y = 'Aogiegiaaayafrwy'

### Community Treasure Hunt

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

Start Hunting!