Cody

# Problem 6. Select every other element of a vector

Solution 2099877

Submitted on 20 Jan 2020 by Yuxuan Deng
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))

ans = 0.2545 0.9681 0.8499 0.7133 0.7858

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

ans = Columns 1 through 18 0.3041 0.8884 0.8698 0.1342 0.1048 0.4722 0.6649 0.6265 0.6803 0.9254 0.5574 0.2543 0.0865 0.7000 0.7650 0.8847 0.2928 0.6788 Columns 19 through 36 0.9355 0.0558 0.2799 0.5676 0.5591 0.2407 0.0870 0.9641 0.5982 0.7871 0.1949 0.7910 0.2313 0.5200 0.2197 0.8138 0.5488 0.1823 Columns 37 through 50 0.2254 0.1231 0.4150 0.7775 0.3261 0.0595 0.2114 0.4106 0.4198 0.3800 0.0537 0.9137 0.3948 0.6635

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))

ans = 'Aogiegiaaayafrwy'