Cody

Problem 6. Select every other element of a vector

Solution 1998876

Submitted on 1 Nov 2019 by Son Pham
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.1296 0.2287 0.2281 0.4671 0.9775

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.4111 0.2230 0.3001 0.3730 0.7625 0.7014 0.6159 0.0269 0.1953 0.4340 0.4896 0.7199 0.5638 0.5891 0.7242 0.1621 0.8995 0.0102 Columns 19 through 36 0.9340 0.4264 0.2445 0.8035 0.4298 0.9072 0.0202 0.8178 0.7712 0.6859 0.3581 0.3298 0.6604 0.6048 0.1591 0.3959 0.6459 0.5396 Columns 37 through 50 0.9405 0.3427 0.6496 0.6605 0.0971 0.1324 0.2015 0.8616 0.6463 0.4867 0.5258 0.8651 0.4336 0.3475

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!