Cody

# Problem 6. Select every other element of a vector

Solution 1157788

Submitted on 9 Apr 2017 by Haokun Qian
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.9576 0.8508 0.2538 0.3118 0.4142

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.5257 0.2464 0.3691 0.7648 0.2874 0.4702 0.5627 0.5519 0.3542 0.0253 0.5453 0.7385 0.3808 0.9027 0.6491 0.6660 0.7414 Columns 18 through 34 0.4529 0.5449 0.5987 0.4704 0.5461 0.7455 0.9436 0.8966 0.2227 0.6403 0.5783 0.7969 0.9066 0.0429 0.7461 0.2067 0.1398 Columns 35 through 50 0.0425 0.8221 0.8450 0.9587 0.6567 0.2949 0.8623 0.0176 0.4161 0.5246 0.5413 0.8221 0.1317 0.1454 0.3864 0.2311

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'