Cody

# Problem 6. Select every other element of a vector

Solution 1789146

Submitted on 16 Apr 2019 by Bridget McFaul
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.7931 0.4908 0.0989 0.4024 0.4521

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.1030 0.6951 0.3631 0.6846 0.8424 0.9310 0.5916 0.3911 0.7443 0.8033 0.8054 0.3705 0.7873 0.8996 0.4450 0.8650 0.9055 0.7506 Columns 19 through 36 0.7177 0.0168 0.5318 0.9496 0.7971 0.8475 0.8084 0.7662 0.3727 0.9977 0.6549 0.9845 0.5151 0.2523 0.9438 0.9861 0.5144 0.6055 Columns 37 through 50 0.7888 0.9210 0.9527 0.8832 0.7767 0.1549 0.0123 0.2775 0.3915 0.2659 0.1384 0.4076 0.3203 0.3355

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'