Cody

# Problem 6. Select every other element of a vector

Solution 1563290

Submitted on 18 Jun 2018 by Sonic Somanna PK
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.8648 0.1352 0.7025 0.6654 0.4587

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.2723 0.7714 0.9947 0.2256 0.3059 0.6060 0.8941 0.7132 0.9140 0.3692 0.0609 0.1416 0.1469 0.7726 0.0636 0.3484 0.1443 0.0164 Columns 19 through 36 0.4955 0.5271 0.2100 0.2164 0.9603 0.1091 0.1777 0.8364 0.8940 0.2854 0.5815 0.4227 0.4650 0.4498 0.1948 0.1488 0.1765 0.7240 Columns 37 through 50 0.9547 0.9682 0.8146 0.2997 0.4790 0.0725 0.4827 0.0473 0.0233 0.3619 0.8523 0.4148 0.9257 0.6308

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!