Cody

# Problem 6. Select every other element of a vector

Solution 2811142

Submitted on 9 Aug 2020 by Gokul Ravi
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.5843 0.2114 0.6711 0.4301 0.2703

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.5153 0.8409 0.7681 0.6635 0.8074 0.0724 0.4244 0.7804 0.9121 0.6561 0.2204 0.6373 0.6435 0.4119 0.2095 0.8899 0.5455 0.5456 Columns 19 through 36 0.9282 0.5208 0.7455 0.0104 0.3277 0.8522 0.0478 0.0600 0.3793 0.8847 0.1723 0.0757 0.7725 0.0726 0.0240 0.6327 0.1471 0.7767 Columns 37 through 50 0.6013 0.2895 0.1669 0.9914 0.8945 0.5490 0.2030 0.9321 0.6241 0.0170 0.1103 0.8926 0.8440 0.9662

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!