Cody

Problem 6. Select every other element of a vector

Solution 2189511

Submitted on 3 Apr 2020 by Anthony DeLucia
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.3656 0.1158 0.2340 0.5565 0.6213

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.8213 0.3444 0.2251 0.0452 0.3657 0.1672 0.3918 0.5188 0.5289 0.4637 0.1284 0.6789 0.6090 0.6534 0.8048 0.8152 0.1757 0.6671 Columns 19 through 36 0.0565 0.3078 0.7129 0.2463 0.2794 0.4666 0.0610 0.8733 0.3139 0.2858 0.0527 0.4836 0.7616 0.6798 0.5646 0.2346 0.0490 0.0737 Columns 37 through 50 0.9300 0.8906 0.5574 0.7628 0.6179 0.6879 0.2653 0.6999 0.3225 0.1987 0.0816 0.2366 0.5611 0.5398

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'