Cody

# Problem 6. Select every other element of a vector

Solution 2930110

Submitted on 9 Sep 2020 by Jackson Torok
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.8691 0.3719 0.1871 0.7552 0.9364

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.7783 0.7501 0.7736 0.6125 0.3118 0.7077 0.2276 0.4347 0.4899 0.8707 0.7155 0.5375 0.0461 0.4120 0.3945 0.0580 0.4588 Columns 18 through 34 0.2554 0.7579 0.8953 0.7807 0.9942 0.9223 0.5560 0.4322 0.7696 0.4470 0.1890 0.9289 0.8057 0.5933 0.1788 0.6057 0.2833 Columns 35 through 50 0.2370 0.6929 0.0313 0.2381 0.6131 0.1845 0.5871 0.0894 0.7453 0.9754 0.5011 0.1652 0.7015 0.4531 0.6833 0.6762

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!