Cody

# Problem 6. Select every other element of a vector

Solution 312641

Submitted on 29 Aug 2013 by Danny Murphy
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))

0.9037 0.3342 0.1978 0.7441 0.4799

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

0.6099 0.8594 0.5767 0.2399 0.0287 0.1679 0.7127 0.4711 0.6820 0.0714 0.0967 0.8175 0.1499 0.5186 0.6490 0.4538 0.8253 0.1332 0.3909 0.8034 0.3993 0.4168 0.6280 0.4317 0.9841 0.1062 0.1981 0.3395 0.9203 0.7379 0.4228 0.9427 0.9831 0.7011 0.5391 0.6665 0.1280 0.1711 0.5612 0.6692 0.3689 0.9816 0.8555 0.3763 0.4283 0.1206 0.2262 0.5830 0.2904 0.2653

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

A o g i e g i a a a y a f r w y