Cody

# Problem 6. Select every other element of a vector

Solution 1907415

Submitted on 21 Aug 2019 by Fitri Suraya
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.3184 0.5060 0.4976 0.3408 0.1630

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.5588 0.7712 0.1745 0.4400 0.6099 0.4595 0.4665 0.6770 0.5593 0.8336 0.1848 0.0510 0.7991 0.7728 0.1101 0.9423 0.6340 0.9984 Columns 19 through 36 0.9361 0.6185 0.7072 0.3506 0.6716 0.0957 0.4896 0.5783 0.2511 0.7859 0.6233 0.5725 0.6650 0.8630 0.7283 0.5087 0.1902 0.7969 Columns 37 through 50 0.6639 0.2015 0.4562 0.5150 0.4718 0.3530 0.2786 0.1347 0.1010 0.9700 0.6434 0.5001 0.1409 0.6685

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'