Cody

# Problem 6. Select every other element of a vector

Solution 1641078

Submitted on 10 Oct 2018 by qiang zhang
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.1470 0.5724 0.6026 0.8620 0.0732

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.9975 0.2576 0.1259 0.3431 0.9892 0.7756 0.1130 0.1559 0.9856 0.6000 0.3584 0.8440 0.9763 0.5245 0.8396 0.7762 0.5705 0.1807 Columns 19 through 36 0.8290 0.7046 0.9408 0.9822 0.8602 0.8812 0.5054 0.2612 0.1359 0.8737 0.1523 0.1236 0.3222 0.5631 0.7367 0.4817 0.3567 0.5258 Columns 37 through 50 0.7338 0.3451 0.2504 0.7773 0.7088 0.6508 0.4793 0.3430 0.2594 0.4334 0.0366 0.0518 0.1701 0.3705

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!