Cody

# Problem 6. Select every other element of a vector

Solution 1048900

Submitted on 9 Nov 2016 by Gustav Lindstrand
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.3822 0.3092 0.9476 0.2968 0.2375

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.9544 0.0105 0.0243 0.1826 0.9893 0.8458 0.4802 0.9146 0.6450 Columns 10 through 18 0.1404 0.2304 0.8912 0.0177 0.7479 0.5595 0.5583 0.0332 0.4074 Columns 19 through 27 0.2575 0.9232 0.1245 0.1460 0.6350 0.3843 0.5124 0.3450 0.9042 Columns 28 through 36 0.9970 0.0826 0.8004 0.8193 0.9097 0.5825 0.4278 0.8754 0.3097 Columns 37 through 45 0.2975 0.1003 0.9862 0.1042 0.6534 0.0829 0.3538 0.0373 0.4278 Columns 46 through 50 0.4766 0.3316 0.0644 0.8800 0.8945

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!