Cody

Problem 6. Select every other element of a vector

Solution 2084776

Submitted on 9 Jan 2020 by Burak Bayrakli
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.2235 0.4767 0.1400 0.0582 0.1216

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

y = Columns 1 through 17 0.9922 0.8072 0.2707 0.7863 0.2072 0.1321 0.4338 0.6522 0.5340 0.9062 0.6338 0.1836 0.3222 0.2489 0.6760 0.9098 0.2294 Columns 18 through 34 0.4448 0.6174 0.2823 0.3639 0.7259 0.5733 0.1868 0.9221 0.6796 0.8887 0.8617 0.0684 0.2984 0.6468 0.5627 0.0695 0.3302 Columns 35 through 50 0.8136 0.9984 0.6467 0.4454 0.3786 0.2816 0.8742 0.0417 0.2881 0.6366 0.0368 0.9504 0.2415 0.3080 0.1680 0.7696

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'