Cody

# Problem 6. Select every other element of a vector

Solution 1247230

Submitted on 7 Aug 2017 by xinyu lei
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.0586 0.9250 0.0584 0.4418 0.1485

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

ans = Columns 1 through 17 0.9367 0.7552 0.2006 0.2412 0.8395 0.8607 0.6867 0.8056 0.2189 0.1452 0.5969 0.3391 0.8479 0.0690 0.7601 0.7552 0.7406 Columns 18 through 34 0.7663 0.8600 0.8218 0.0925 0.5704 0.4527 0.6857 0.4593 0.8619 0.9196 0.5140 0.9416 0.6717 0.5902 0.6315 0.6839 0.7463 Columns 35 through 50 0.2893 0.6257 0.1739 0.6513 0.3853 0.8605 0.8229 0.9544 0.9715 0.3922 0.6976 0.7306 0.0303 0.8817 0.6772 0.9416

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'