Cody

# Problem 6. Select every other element of a vector

Solution 987471

Submitted on 30 Sep 2016 by Cody Saunders
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.3046 0.1118 0.8165 0.2555 0.2482

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

y = Columns 1 through 9 0.0669 0.5549 0.5316 0.4065 0.9331 0.3592 0.5854 0.6146 0.3907 Columns 10 through 18 0.9880 0.8062 0.9770 0.7229 0.0911 0.9780 0.9136 0.4317 0.1084 Columns 19 through 27 0.7560 0.6849 0.6226 0.6929 0.6987 0.5195 0.7552 0.4208 0.7610 Columns 28 through 36 0.2655 0.9487 0.9522 0.5665 0.0934 0.0107 0.4687 0.7737 0.1061 Columns 37 through 45 0.2055 0.5916 0.6509 0.7671 0.6481 0.8569 0.6842 0.8961 0.3747 Columns 46 through 50 0.5525 0.1972 0.8515 0.2614 0.5476

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!