Cody

# Problem 6. Select every other element of a vector

Solution 3411068

Submitted on 26 Oct 2020 by Joseph Dillon
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.1643 0.3617 0.6220 0.8363 0.9275

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.1428 0.6612 0.5295 0.2753 0.1893 0.8925 0.1100 0.2507 0.9888 0.2400 0.3005 0.8439 0.2859 0.9520 0.5423 0.9986 0.2920 Columns 18 through 34 0.3191 0.4828 0.5594 0.9604 0.2349 0.0162 0.7424 0.0925 0.8053 0.5485 0.9950 0.6308 0.4487 0.3054 0.3849 0.0053 0.9329 Columns 35 through 50 0.0770 0.0135 0.7861 0.6511 0.2761 0.5881 0.1994 0.7921 0.2139 0.1689 0.8833 0.4911 0.1203 0.0046 0.3692 0.1936

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!