Cody

# Problem 6. Select every other element of a vector

Solution 1258467

Submitted on 28 Aug 2017 by Andy Seeder
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.3748 0.6038 0.7590 0.4543 0.4148

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

ans = Columns 1 through 17 0.1633 0.3062 0.0212 0.8857 0.4876 0.8929 0.5216 0.7025 0.8057 0.0224 0.0233 0.1277 0.5781 0.1773 0.0019 0.8163 0.0110 Columns 18 through 34 0.7737 0.0067 0.3297 0.6348 0.6855 0.4257 0.9284 0.7932 0.4644 0.9717 0.9744 0.2556 0.5355 0.8733 0.2962 0.7643 0.7815 Columns 35 through 50 0.0917 0.0891 0.9756 0.0207 0.9684 0.0122 0.5670 0.0991 0.5934 0.6266 0.4545 0.1871 0.6973 0.7683 0.5255 0.1531

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!