Cody

# Problem 6. Select every other element of a vector

Solution 1847939

Submitted on 12 Jun 2019 by Ankit Kumar Mishra
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.1548 0.6891 0.1309 0.9483 0.7509

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.6369 0.7069 0.2113 0.7575 0.7500 0.6807 0.8974 0.1847 0.8577 0.1308 0.6124 0.2152 0.1503 0.2794 0.5574 0.6618 0.2669 0.6865 Columns 19 through 36 0.5519 0.1915 0.5925 0.6550 0.3910 0.6759 0.6038 0.5477 0.9722 0.1972 0.5058 0.9380 0.2642 0.5773 0.6788 0.5540 0.4683 0.7295 Columns 37 through 50 0.8313 0.6485 0.7787 0.8556 0.9048 0.9437 0.6683 0.4858 0.5932 0.9824 0.2877 0.2967 0.5215 0.7319

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!