Cody

Problem 6. Select every other element of a vector

Solution 1517125

Submitted on 4 May 2018 by Aakash Sharma
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.0850 0.9916 0.9492 0.8333 0.7424

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.6264 0.5165 0.3678 0.4969 0.6872 0.6657 0.1771 0.7553 0.5658 0.7747 0.6892 0.2876 0.0734 0.8222 0.6750 0.7793 0.7126 0.8534 Columns 19 through 36 0.2001 0.6514 0.9998 0.7975 0.6539 0.9980 0.2225 0.1906 0.6206 0.9957 0.3098 0.9435 0.3456 0.8424 0.5007 0.0043 0.6046 0.2180 Columns 37 through 50 0.0732 0.6776 0.6799 0.1471 0.9367 0.2330 0.0654 0.5437 0.7563 0.5483 0.4711 0.1248 0.0274 0.9069

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!