Cody

Problem 6. Select every other element of a vector

Solution 3348503

Submitted on 23 Oct 2020 by Hossein Kalhori
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.2467 0.2597 0.8504 0.8312 0.4039

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.9339 0.3188 0.1919 0.5610 0.2861 0.9099 0.3096 0.7610 0.5793 0.0796 0.6480 0.4725 0.1346 0.9284 0.7999 0.3660 0.7668 Columns 18 through 34 0.6386 0.8161 0.9218 0.1373 0.5122 0.5787 0.1560 0.2890 0.4747 0.3186 0.4843 0.0745 0.6627 0.2620 0.6925 0.2332 0.3160 Columns 35 through 50 0.4480 0.1838 0.3219 0.8862 0.2091 0.3334 0.3829 0.4380 0.1266 0.5054 0.7026 0.2783 0.6540 0.7907 0.8199 0.1292

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!