Cody

# Problem 6. Select every other element of a vector

Solution 2182860

Submitted on 30 Mar 2020 by Jeff Connors
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.6767 0.1166 0.3582 0.2112 0.1783

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.8989 0.0583 0.1341 0.7764 0.2913 0.2582 0.6321 0.9936 0.6073 0.6169 0.3687 0.2361 0.5671 0.0295 0.5954 0.0329 0.2616 0.9223 Columns 19 through 36 0.9942 0.5474 0.7685 0.0791 0.3118 0.5393 0.3192 0.1543 0.7646 0.1545 0.4517 0.7897 0.6228 0.3879 0.7881 0.2434 0.2410 0.0931 Columns 37 through 50 0.3168 0.4684 0.5320 0.4605 0.8647 0.7042 0.9405 0.3034 0.8032 0.4064 0.6218 0.7790 0.8735 0.2633

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!