Cody

# Problem 6. Select every other element of a vector

Solution 1819321

Submitted on 18 May 2019 by Yesenia Joe
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))

n = 10 y = 0.9852 0.2748 0.4239 0.9756 0.1018

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

n = 100 y = Columns 1 through 18 0.2171 0.4469 0.1879 0.9417 0.6991 0.1616 0.4553 0.4504 0.8821 0.2226 0.4930 0.4042 0.1805 0.6888 0.9279 0.4300 0.9404 0.9362 Columns 19 through 36 0.2052 0.4890 0.7423 0.3528 0.2851 0.0927 0.6476 0.8145 0.5360 0.5296 0.8448 0.0082 0.6874 0.6736 0.4386 0.2352 0.3118 0.8264 Columns 37 through 50 0.1401 0.2031 0.1253 0.8697 0.3176 0.0041 0.5904 0.0219 0.6937 0.9066 0.7992 0.9510 0.6386 0.3806

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

n = 31 y = 'Aogiegiaaayafrwy'