Cody

# Problem 6. Select every other element of a vector

Solution 2014618

Submitted on 11 Nov 2019 by Mehran Akbari
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.5569 0.6668 0.9091 0.8170 0.8340

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.9587 0.5077 0.6246 0.9135 0.7268 0.4516 0.4210 0.5058 0.4864 0.2376 0.6806 0.2851 0.4696 0.7761 0.5694 0.7833 0.6809 0.2910 Columns 19 through 36 0.2867 0.5697 0.3395 0.9968 0.1796 0.5442 0.1884 0.2642 0.6892 0.5890 0.6391 0.9763 0.2211 0.6302 0.1676 0.7023 0.6163 0.2832 Columns 37 through 50 0.3749 0.8754 0.6216 0.4588 0.6556 0.0837 0.7383 0.6596 0.6014 0.1351 0.1988 0.1438 0.4965 0.6782

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!