Cody

Problem 6. Select every other element of a vector

Solution 892086

Submitted on 20 May 2016 by Dennis Winston
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.1859 0.4805 0.4375 0.0563 0.1625

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = Columns 1 through 9 0.0396 0.1139 0.0296 0.4647 0.1825 0.7517 0.6789 0.6828 0.1429 Columns 10 through 18 0.0475 0.3315 0.7869 0.9625 0.5987 0.5902 0.2271 0.1137 0.8212 Columns 19 through 27 0.3258 0.2677 0.5036 0.1745 0.5975 0.5774 0.5848 0.8190 0.1304 Columns 28 through 36 0.1626 0.2930 0.4147 0.6360 0.5285 0.4947 0.4313 0.0026 0.3222 Columns 37 through 45 0.1897 0.7441 0.7134 0.9520 0.4830 0.9015 0.1473 0.5714 0.7037 Columns 46 through 50 0.1257 0.3098 0.4119 0.1668 0.2041

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!