Cody

# Problem 6. Select every other element of a vector

Solution 928393

Submitted on 27 Jul 2016 by Jakub Galecki
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.1839 0.8397 0.4876 0.8116 0.8113

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

y = Columns 1 through 9 0.6814 0.6316 0.7905 0.3924 0.5426 0.5480 0.1805 0.7381 0.7963 Columns 10 through 18 0.9197 0.6739 0.9615 0.4900 0.0088 0.0926 0.1919 0.2741 0.9599 Columns 19 through 27 0.4989 0.4233 0.5757 0.4763 0.7556 0.9912 0.6660 0.9244 0.2131 Columns 28 through 36 0.4513 0.3981 0.0770 0.3524 0.4807 0.7195 0.6474 0.4568 0.1362 Columns 37 through 45 0.4744 0.1349 0.2621 0.9411 0.4807 0.4396 0.9814 0.2841 0.0336 Columns 46 through 50 0.9444 0.3750 0.7239 0.4695 0.6337

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!