Cody

Problem 6. Select every other element of a vector

Solution 1022374

Submitted on 19 Oct 2016 by FCSmith
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.4360 0.2888 0.7199 0.1925 0.2090

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.4001 0.9767 0.7056 0.7877 0.4161 0.5060 0.8645 0.4401 0.7502 Columns 10 through 18 0.1186 0.2101 0.3348 0.5183 0.1957 0.3572 0.9739 0.2123 0.5529 Columns 19 through 27 0.8032 0.3762 0.9581 0.7597 0.4771 0.0359 0.9705 0.7190 0.4350 Columns 28 through 36 0.5075 0.7758 0.9324 0.3168 0.0917 0.2998 0.0548 0.5163 0.0639 Columns 37 through 45 0.9902 0.7302 0.8294 0.5648 0.0840 0.4070 0.9131 0.8263 0.8531 Columns 46 through 50 0.9367 0.2843 0.0207 0.3328 0.5839

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!