Cody

# Problem 6. Select every other element of a vector

Solution 2655260

Submitted on 5 Jul 2020 by mohsen
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.4597 0.6891 0.9374 0.4671 0.3862

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.0581 0.7773 0.5373 0.8869 0.5371 0.1597 0.9223 0.0990 0.3859 0.1066 0.2169 0.7540 0.2826 0.1232 0.1732 0.1816 0.6418 0.4655 Columns 19 through 36 0.8336 0.3440 0.2839 0.1468 0.6951 0.8415 0.2778 0.3679 0.1277 0.7385 0.2336 0.1915 0.3109 0.8196 0.0896 0.4394 0.7179 0.8028 Columns 37 through 50 0.7371 0.5443 0.1939 0.2263 0.2503 0.5282 0.6408 0.1343 0.2815 0.7624 0.6821 0.3306 0.4418 0.4637

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!