Cody

# Problem 6. Select every other element of a vector

Solution 238557

Submitted on 1 May 2013 by Anirudh Iyer
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))

n = 1 m = 10 y = 0.3445 0.6753 0.6022 0.9160 0.4624

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

n = 1 m = 100 y = Columns 1 through 10 0.4609 0.3225 0.4714 0.1759 0.4735 0.3411 0.1917 0.2428 0.2691 0.1887 Columns 11 through 20 0.0911 0.6834 0.4257 0.6476 0.6358 0.2089 0.2362 0.6073 0.4587 0.7703 Columns 21 through 30 0.6620 0.8419 0.2564 0.5822 0.8699 0.3181 0.9398 0.4795 0.5447 0.5439 Columns 31 through 40 0.5225 0.2187 0.1097 0.4046 0.3658 0.6279 0.9329 0.1920 0.6963 0.5254 Columns 41 through 50 0.8611 0.3935 0.7413 0.3477 0.5861 0.0445 0.2428 0.6878 0.7363 0.6834

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

n = 1 m = 31 y = Aogiegiaaayafrwy