Cody

# Problem 6. Select every other element of a vector

Solution 3023131

Submitted on 1 Oct 2020 by Anudeep Chowdary Kamepalli
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.8313 0.1565 0.9369 0.6691 0.7367

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.4259 0.6759 0.1165 0.0164 0.6513 0.6480 0.3032 0.8728 0.7177 0.7571 0.3009 0.9251 0.1409 0.6826 0.2448 0.5774 0.7974 Columns 18 through 34 0.7919 0.2951 0.5453 0.8534 0.3098 0.0061 0.8773 0.1338 0.0840 0.3931 0.2021 0.4976 0.7553 0.7264 0.4658 0.5380 0.4016 Columns 35 through 50 0.7686 0.9000 0.6980 0.8908 0.7608 0.0616 0.5955 0.2467 0.1937 0.5674 0.4716 0.3627 0.3933 0.7500 0.9580 0.8279

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!