Cody

# Problem 6. Select every other element of a vector

Solution 2119865

Submitted on 6 Feb 2020 by Rashmi Upase
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.7615 0.6935 0.1837 0.8797 0.6997

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.5193 0.3625 0.0024 0.0051 0.3859 0.3710 0.8941 0.7638 0.0392 0.2239 0.1593 0.3385 0.3715 0.8571 0.9199 0.6224 0.4594 0.3153 Columns 19 through 36 0.2158 0.9049 0.8891 0.4861 0.0763 0.9768 0.5484 0.0366 0.5664 0.4065 0.9238 0.9634 0.6604 0.4747 0.7008 0.2055 0.0336 0.3697 Columns 37 through 50 0.5961 0.2546 0.2020 0.8295 0.9778 0.4414 0.0802 0.2390 0.0319 0.0416 0.6280 0.3894 0.3310 0.7855

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!