Cody

# Problem 6. Select every other element of a vector

Solution 3356073

Submitted on 24 Oct 2020 by Muhammad Zain Khan
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.1197 0.5086 0.0923 0.5360 0.0500

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.1142 0.7499 0.0545 0.9817 0.6474 0.2956 0.3586 0.3745 0.7887 0.6601 0.9585 0.0015 0.0816 0.4794 0.5423 0.4967 0.0311 Columns 18 through 34 0.3474 0.7980 0.9113 0.6554 0.5846 0.9300 0.9285 0.0071 0.0925 0.7435 0.7256 0.0927 0.9312 0.9618 0.7665 0.6619 0.5608 Columns 35 through 50 0.5302 0.6891 0.8793 0.8101 0.7806 0.0556 0.8930 0.7119 0.4373 0.3720 0.9388 0.9566 0.0963 0.5743 0.7430 0.8385

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'

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!