Cody

Problem 6. Select every other element of a vector

Solution 1815575

Submitted on 15 May 2019 by Joan Watson
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.1457 0.7806 0.5408 0.1798 0.1824

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.9518 0.5994 0.0961 0.6319 0.2902 0.0597 0.9993 0.8220 0.8388 0.8960 0.5638 0.2414 0.0738 0.8412 0.7079 0.7775 0.2173 0.3113 Columns 19 through 36 0.2684 0.0255 0.1640 0.6484 0.7215 0.2379 0.9025 0.7186 0.5781 0.8081 0.0291 0.0020 0.2630 0.0236 0.7486 0.6810 0.9322 0.9584 Columns 37 through 50 0.0454 0.4785 0.8274 0.0408 0.9032 0.0991 0.4546 0.3114 0.6993 0.9761 0.9532 0.8160 0.0259 0.5460

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'