Cody

Problem 6. Select every other element of a vector

Solution 3320953

Submitted on 22 Oct 2020 by 윤하 홍
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.0526 0.8517 0.2626 0.1486 0.3098

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.5124 0.5945 0.7006 0.0062 0.1552 0.2665 0.7721 0.0765 0.9454 0.9055 0.9162 0.8919 0.7330 0.5991 0.2815 0.3231 0.1718 0.0261 Columns 19 through 36 0.6230 0.9245 0.9195 0.8202 0.3673 0.1207 0.1258 0.3659 0.3621 0.6706 0.1707 0.8541 0.7361 0.6901 0.1504 0.2667 0.0131 0.7168 Columns 37 through 50 0.0670 0.8244 0.7399 0.3502 0.9416 0.7356 0.6593 0.1123 0.9367 0.9345 0.1096 0.8355 0.5617 0.9770

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!