Cody

# Problem 6. Select every other element of a vector

Solution 2743999

Submitted on 27 Jul 2020 by Hassan Mehmood Khan
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.8476 0.6372 0.9842 0.4777 0.5313

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.7515 0.3908 0.7683 0.8965 0.5440 0.7694 0.4164 0.5287 0.3728 0.4269 0.5418 0.5315 0.5985 0.4295 0.0989 0.7532 0.6403 0.5355 Columns 19 through 36 0.7774 0.0709 0.3383 0.7977 0.6141 0.6537 0.7556 0.2734 0.2319 0.9577 0.2984 0.5369 0.0049 0.1878 0.7859 0.9275 0.9443 0.0634 Columns 37 through 50 0.3383 0.5429 0.4113 0.6759 0.3627 0.2722 0.7587 0.1915 0.4171 0.7386 0.2039 0.7425 0.5189 0.0494

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!