Cody

# Problem 6. Select every other element of a vector

Solution 1398581

Submitted on 30 Dec 2017 by Kavithaa
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.0947 0.4070 0.8804 0.5773 0.7029

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.4249 0.7856 0.2431 0.0886 0.0927 0.6108 0.7876 0.1255 0.8155 0.9532 0.3432 0.7840 0.5097 0.9939 0.4923 0.5980 0.3614 Columns 18 through 34 0.7407 0.6149 0.5758 0.3638 0.3569 0.0284 0.1051 0.8990 0.8757 0.6293 0.3677 0.4409 0.2057 0.2887 0.9034 0.5880 0.4764 Columns 35 through 50 0.1316 0.5628 0.2649 0.2353 0.4733 0.0383 0.0101 0.7041 0.0329 0.0725 0.0886 0.2109 0.5999 0.9544 0.6699 0.4688

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'