Cody

# Problem 6. Select every other element of a vector

Solution 2966512

Submitted on 19 Sep 2020 by Levente Dáms
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.3964 0.4633 0.8519 0.1312 0.0340

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.4933 0.2888 0.3693 0.7234 0.6121 0.8899 0.6266 0.7318 0.3855 0.5078 0.7366 0.3932 0.7299 0.3358 0.4393 0.2918 0.2719 Columns 18 through 34 0.8650 0.7757 0.3519 0.4675 0.6917 0.2726 0.4699 0.8772 0.0291 0.2423 0.3691 0.4793 0.6419 0.5560 0.5179 0.2929 0.0918 Columns 35 through 50 0.6907 0.0697 0.7033 0.4903 0.6513 0.7329 0.9501 0.8590 0.5286 0.1950 0.3366 0.9046 0.8853 0.6172 0.0549 0.3905

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!