Cody

# Problem 6. Select every other element of a vector

Solution 1862996

Submitted on 2 Jul 2019 by Rajat Gupta
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.7815 0.0264 0.6819 0.2187 0.0411

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

ans = Columns 1 through 17 0.7508 0.8464 0.6784 0.2256 0.0606 0.1704 0.2981 0.7174 0.3782 0.3797 0.8616 0.0470 0.9323 0.8322 0.1737 0.7566 0.2920 Columns 18 through 34 0.3570 0.9574 0.4870 0.4869 0.4839 0.0942 0.0983 0.9852 0.1375 0.7202 0.5014 0.7606 0.6031 0.7950 0.3206 0.2202 0.9500 Columns 35 through 50 0.8209 0.3824 0.3531 0.4966 0.9386 0.3679 0.8648 0.4395 0.7453 0.4009 0.6992 0.8490 0.0532 0.9625 0.0367 0.7128

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'