Cody

# Problem 6. Select every other element of a vector

Solution 2049042

Submitted on 6 Dec 2019 by Brandon koehler
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))

ans = 0.9538 0.3868 0.9546 0.0881 0.9829

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

ans = Columns 1 through 18 0.4252 0.0825 0.0983 0.4745 0.2682 0.6734 0.1844 0.8901 0.0275 0.2809 0.9374 0.1565 0.1628 0.3435 0.5518 0.8050 0.6492 0.3209 Columns 19 through 36 0.0261 0.1422 0.9450 0.8724 0.2849 0.5893 0.8832 0.6247 0.3662 0.6048 0.1241 0.1238 0.4048 0.0734 0.3644 0.5812 0.3286 0.4032 Columns 37 through 50 0.2444 0.4630 0.6644 0.8108 0.1431 0.1195 0.6901 0.3268 0.0808 0.0563 0.7899 0.4710 0.4735 0.6382

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))

ans = 'Aogiegiaaayafrwy'