Cody

# Problem 6. Select every other element of a vector

Solution 3434173

Submitted on 27 Oct 2020 at 9:58 by Raul De la Fuente
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.2527 0.0886 0.9055 0.7803 0.3445

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.5486 0.7840 0.3578 0.0015 0.5279 0.9511 0.7501 0.4669 0.8720 0.4526 0.6043 0.8907 0.8444 0.4934 0.7340 0.0268 0.7849 Columns 18 through 34 0.6831 0.6616 0.4950 0.2318 0.3932 0.4122 0.2274 0.6966 0.0722 0.8047 0.7575 0.4201 0.0479 0.6847 0.2527 0.2887 0.0512 Columns 35 through 50 0.0669 0.9481 0.6408 0.9605 0.8758 0.7765 0.2518 0.7908 0.6574 0.1670 0.7706 0.4709 0.1187 0.4962 0.7296 0.1349

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!