Cody

# Problem 6. Select every other element of a vector

Solution 1909026

Submitted on 22 Aug 2019 by Jennifer Winikus
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))

n = 10 y = [] y = 0.0578 0.5315 0.8496 0.6905 0.0208

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

n = 100 y = [] y = Columns 1 through 17 0.3534 0.9609 0.3266 0.6072 0.9514 0.6036 0.6489 0.6291 0.8279 0.0645 0.6171 0.7949 0.4476 0.1387 0.6688 0.9156 0.3977 Columns 18 through 34 0.8942 0.9837 0.6281 0.9092 0.5150 0.6699 0.4824 0.5913 0.3911 0.9037 0.1859 0.2794 0.4482 0.0510 0.6700 0.1432 0.2555 Columns 35 through 50 0.2755 0.4433 0.2447 0.6373 0.4739 0.9343 0.4137 0.4952 0.2386 0.9621 0.6913 0.9800 0.7519 0.9921 0.2906 0.0916

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))

n = 31 y = [] y = 'Aogiegiaaayafrwy'

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!