Cody

Problem 6. Select every other element of a vector

Solution 1575755

Submitted on 4 Jul 2018 by Ryan Manzuk
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.8431 0.3555 0.8343 0.9076 0.2631

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.7666 0.9475 0.6781 0.8132 0.5073 0.3799 0.4682 0.5350 0.0569 0.3853 0.3105 0.1903 0.9885 0.5382 0.6255 0.5202 0.0077 Columns 18 through 34 0.5478 0.1320 0.9322 0.2875 0.2666 0.7822 0.5565 0.4167 0.0574 0.4941 0.4444 0.8601 0.1709 0.0355 0.3267 0.2648 0.0475 Columns 35 through 50 0.2160 0.7778 0.8243 0.0312 0.9709 0.6581 0.2366 0.8331 0.4142 0.5832 0.4904 0.6147 0.9937 0.0513 0.5962 0.9919

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!