Cody

# Problem 6. Select every other element of a vector

Solution 3282508

Submitted on 19 Oct 2020 by Na Cl
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.0219 0.1628 0.9091 0.9581 0.3282

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.0325 0.6176 0.8404 0.5534 0.7107 0.2476 0.9061 0.1144 0.3576 0.7563 0.1060 0.2878 0.6911 0.2314 0.7542 0.6938 0.6547 Columns 18 through 34 0.4708 0.6342 0.4426 0.4960 0.7857 0.0859 0.0391 0.0211 0.8273 0.3722 0.6375 0.3354 0.8202 0.8144 0.4134 0.9004 0.6560 Columns 35 through 50 0.5429 0.5658 0.4506 0.2135 0.6941 0.4382 0.3653 0.8660 0.9166 0.5827 0.3936 0.4667 0.5855 0.3381 0.2126 0.2120

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!