Cody

Problem 6. Select every other element of a vector

Solution 1989988

Submitted on 24 Oct 2019 by Nikolaj Maack Bielefeld
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.1148 0.3458 0.5018 0.6671 0.5993

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.7444 0.9206 0.7138 0.9202 0.0182 0.7531 0.3130 0.0979 0.4988 0.4899 0.1120 0.5494 0.0486 0.6584 0.7129 0.0222 0.3496 0.8751 Columns 19 through 36 0.9081 0.6242 0.8631 0.7899 0.4187 0.1473 0.6087 0.8135 0.3089 0.7995 0.5735 0.4534 0.5939 0.3312 0.6828 0.0572 0.4617 0.7955 Columns 37 through 50 0.4849 0.1247 0.1011 0.7271 0.2783 0.4012 0.8475 0.3697 0.9850 0.4359 0.6689 0.0532 0.3498 0.9830

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'