Cody

# Problem 6. Select every other element of a vector

Solution 2652125

Submitted on 4 Jul 2020 by Gregory Bohorquez
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.4039 0.9450 0.3174 0.3702 0.5254

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.2091 0.8544 0.1121 0.1059 0.6180 0.4030 0.7870 0.8451 0.9720 0.0639 0.5895 0.1800 0.6007 0.1552 0.6212 0.6546 0.9573 Columns 18 through 34 0.0385 0.2200 0.5583 0.3593 0.4795 0.6927 0.7082 0.4762 0.4805 0.9681 0.1295 0.3554 0.2543 0.9023 0.4391 0.8271 0.6803 Columns 35 through 50 0.0398 0.1840 0.7260 0.7051 0.7437 0.5175 0.3523 0.4917 0.7561 0.3222 0.5960 0.0677 0.7721 0.1190 0.7343 0.8815

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!