Cody

# Problem 6. Select every other element of a vector

Solution 1323463

Submitted on 1 Nov 2017 by Harvey Eldridge
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.4397 0.2128 0.2568 0.3326 0.9817

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.7336 0.1089 0.6505 0.3454 0.5766 0.6582 0.2350 0.6841 0.8309 0.8361 0.2730 0.5389 0.0898 0.4973 0.7879 0.3530 0.9694 0.5883 Columns 19 through 36 0.7077 0.4251 0.7852 0.0221 0.4986 0.7568 0.6290 0.2838 0.5210 0.0274 0.8389 0.5550 0.9584 0.7655 0.9844 0.5461 0.4333 0.8840 Columns 37 through 50 0.3911 0.7290 0.7459 0.9439 0.7393 0.6572 0.9743 0.1609 0.6856 0.7112 0.5207 0.6417 0.5144 0.7271

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!