Cody

Problem 6. Select every other element of a vector

Solution 2160785

Submitted on 15 Mar 2020 by deandre vodka
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.8579 0.9765 0.0982 0.8324 0.1859

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.6476 0.1848 0.3470 0.1262 0.4803 0.5743 0.9251 0.0119 0.7339 0.2445 0.7481 0.5688 0.5834 0.4131 0.0274 0.2226 0.9680 0.2144 Columns 19 through 36 0.1995 0.6904 0.0824 0.9668 0.9461 0.8552 0.8701 0.9981 0.5005 0.7166 0.8588 0.1927 0.6721 0.3393 0.4554 0.1252 0.7975 0.8638 Columns 37 through 50 0.0530 0.2659 0.7804 0.8637 0.3471 0.1069 0.9829 0.5408 0.1012 0.0577 0.2307 0.0532 0.8319 0.8332

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'

Suggested Problems

More from this Author95

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!