Cody

# Problem 6. Select every other element of a vector

Solution 2389113

Submitted on 27 May 2020 by Cem Bozkurt
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.8251 0.1842 0.9680 0.3824 0.6868

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.1763 0.5676 0.2216 0.3004 0.7174 0.3348 0.9890 0.4463 0.4231 0.6904 0.7314 0.4601 0.2491 0.9384 0.7366 0.2491 0.3337 0.7149 Columns 19 through 36 0.1372 0.2950 0.1220 0.2090 0.1720 0.9591 0.2490 0.3762 0.3801 0.9595 0.1742 0.4743 0.7434 0.2198 0.8707 0.5591 0.9051 0.8182 Columns 37 through 50 0.6758 0.0089 0.6761 0.5690 0.5339 0.7296 0.7674 0.7287 0.7036 0.1652 0.7618 0.2386 0.5882 0.7930

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!