Cody

# Problem 6. Select every other element of a vector

Solution 1145223

Submitted on 24 Mar 2017 by Isaac Abraham
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.3521 0.1853 0.4710 0.0639 0.6818

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.4301 0.6557 0.0969 0.2609 0.4278 0.5897 0.5194 0.2943 0.1285 0.9590 0.0602 0.4063 0.1359 0.3179 0.1429 0.8566 0.2542 Columns 18 through 34 0.2717 0.0399 0.1684 0.7688 0.8862 0.0542 0.0911 0.0981 0.1959 0.5590 0.2380 0.7066 0.4259 0.9125 0.4131 0.6856 0.4394 Columns 35 through 50 0.7612 0.4498 0.2437 0.8741 0.5431 0.4327 0.1216 0.0466 0.0112 0.2827 0.4647 0.5089 0.2695 0.2987 0.4452 0.8430

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!