Cody

# Problem 6. Select every other element of a vector

Solution 3004681

Submitted on 29 Sep 2020 by Hasnaine Hasib
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))

0.1950 0.7629 0.0040 0.2131 0.4559

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

Columns 1 through 17 0.0896 0.3032 0.3295 0.6662 0.6067 0.7871 0.6600 0.1907 0.8268 0.0986 0.1343 0.4697 0.0691 0.4951 0.5483 0.2016 0.0450 Columns 18 through 34 0.4739 0.9939 0.1569 0.8461 0.0507 0.8797 0.4053 0.7383 0.4647 0.7367 0.8135 0.1488 0.0013 0.7095 0.0895 0.7206 0.8238 Columns 35 through 50 0.9261 0.5468 0.5966 0.2702 0.4945 0.8003 0.6744 0.3436 0.2662 0.2823 0.8966 0.9894 0.3732 0.7718 0.3872 0.3414

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))

Aogiegiaaayafrwy

### Community Treasure Hunt

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

Start Hunting!