Cody

# Problem 6. Select every other element of a vector

Solution 2255183

Submitted on 5 May 2020 by Arif Istiak Abeg
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.4578 0.7003 0.1595 0.5518 0.0499

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.8185 0.4521 0.5837 0.6321 0.3652 0.9364 0.5351 0.2632 0.3140 0.3364 0.6790 0.7621 0.3173 0.8656 0.5574 0.5892 0.4281 0.7566 Columns 19 through 36 0.1374 0.5357 0.8223 0.6677 0.1987 0.0816 0.2197 0.9045 0.0130 0.1590 0.4653 0.1813 0.7589 0.6244 0.8338 0.9546 0.7063 0.7781 Columns 37 through 50 0.2752 0.6080 0.0656 0.0237 0.9713 0.2787 0.4032 0.9053 0.5432 0.8270 0.1870 0.1039 0.9264 0.0343

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!