Cody

Problem 6. Select every other element of a vector

Solution 1218864

Submitted on 23 Jun 2017 by Salvatore Lacava
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))

y = 0.6202 0.7882 0.1407 0.9549 0.6077

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

y = Columns 1 through 18 0.3257 0.6403 0.2629 0.0983 0.0354 0.1125 0.5579 0.3426 0.4779 0.8584 0.1094 0.4564 0.7887 0.0058 0.4010 0.1066 0.0676 0.3368 Columns 19 through 36 0.9619 0.7987 0.8349 0.3521 0.8925 0.6895 0.0687 0.4172 0.1661 0.0959 0.4378 0.0040 0.5951 0.2380 0.6354 0.8976 0.9928 0.9054 Columns 37 through 50 0.0451 0.8427 0.9353 0.9250 0.5485 0.4731 0.5302 0.2811 0.3062 0.2044 0.9795 0.5212 0.7563 0.1319

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

y = 'Aogiegiaaayafrwy'