Cody

# Problem 6. Select every other element of a vector

Solution 917277

Submitted on 30 Jun 2016 by Guy Giesa-Wilson
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.7546 0.8102 0.2655 0.6589 0.5169

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = Columns 1 through 9 0.8341 0.5372 0.3267 0.8695 0.2423 0.1528 0.4307 0.9025 0.4104 Columns 10 through 18 0.2571 0.4970 0.8584 0.9610 0.7489 0.9678 0.3646 0.9791 0.9042 Columns 19 through 27 0.6602 0.7410 0.5615 0.7877 0.1199 0.9303 0.0356 0.6562 0.4852 Columns 28 through 36 0.5556 0.1457 0.5627 0.4834 0.2031 0.3264 0.3362 0.7830 0.8334 Columns 37 through 45 0.8665 0.7620 0.2205 0.4015 0.0270 0.9637 0.0384 0.2262 0.4776 Columns 46 through 50 0.2968 0.1990 0.6188 0.7563 0.5371

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!