Cody

# Problem 6. Select every other element of a vector

Solution 2810029

Submitted on 8 Aug 2020 by Madhav kolgaonkar
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.5973 0.8454 0.7483 0.9741 0.6539

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.5733 0.2143 0.3388 0.2420 0.3787 0.5335 0.0224 0.9905 0.6792 0.0729 0.4267 0.6547 0.6495 0.6505 0.0240 0.6377 0.3626 0.6048 Columns 19 through 36 0.1334 0.0515 0.4607 0.8793 0.6559 0.5074 0.1557 0.4578 0.4823 0.9221 0.4608 0.2096 0.4377 0.5745 0.5759 0.4841 0.6742 0.7279 Columns 37 through 50 0.7892 0.7305 0.9461 0.4676 0.8460 0.8953 0.2561 0.7199 0.0157 0.2085 0.6369 0.9698 0.5116 0.7657

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!