Cody

# Problem 6. Select every other element of a vector

Solution 3767753

Submitted on 21 Nov 2020 by Mary Altmire
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.7794 0.1183 0.0180 0.0733 0.2960

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

y = Columns 1 through 17 0.4442 0.7877 0.4547 0.4443 0.4849 0.8490 0.8087 0.9034 0.3875 0.5982 0.5920 0.4444 0.7601 0.1459 0.6340 0.4683 0.3265 Columns 18 through 34 0.6811 0.6561 0.8820 0.8897 0.2056 0.2550 0.9876 0.9387 0.4159 0.9876 0.5568 0.0420 0.7003 0.2783 0.6759 0.9399 0.3855 Columns 35 through 50 0.2096 0.8905 0.7845 0.2958 0.6448 0.1767 0.9055 0.3652 0.3329 0.6512 0.8195 0.7692 0.0458 0.0548 0.2063 0.4818

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!