Cody

Problem 6. Select every other element of a vector

Solution 1442047

Submitted on 16 Feb 2018 by Michael Holme Sørensen
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))

sd = 0.8083 0.5527 0.1158 0.0857 0.5500

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

sd = Columns 1 through 17 0.4017 0.5754 0.3973 0.8247 0.5572 0.3760 0.7935 0.3816 0.1962 0.0470 0.8705 0.6221 0.7098 0.1580 0.8146 0.0425 0.2994 Columns 18 through 34 0.4333 0.0718 0.9947 0.5279 0.3140 0.7439 0.3434 0.4053 0.7361 0.4949 0.0413 0.5817 0.2623 0.7142 0.2720 0.2223 0.7622 Columns 35 through 50 0.6388 0.8863 0.5214 0.4171 0.3780 0.4360 0.0502 0.3032 0.1390 0.0549 0.6952 0.5375 0.4145 0.4924 0.1409 0.5709

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

sd = 'Aogiegiaaayafrwy'