Cody

# Problem 6. Select every other element of a vector

Solution 702443

Submitted on 17 Jul 2015 by Stephen
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 = [] y = 0.3362 y = 0.3362 0.7778 y = 0.3362 0.7778 0.2095 y = 0.3362 0.7778 0.2095 0.6936 y = 0.3362 0.7778 0.2095 0.6936 0.3124

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

y = [] y = 0.2594 y = 0.2594 0.5155 y = 0.2594 0.5155 0.2883 y = 0.2594 0.5155 0.2883 0.8932 y = 0.2594 0.5155 0.2883 0.8932 0.5372 y = 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 y = 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 y = 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 y = 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Column 10 0.8795 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 11 0.8795 0.6421 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 12 0.8795 0.6421 0.7936 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 13 0.8795 0.6421 0.7936 0.4713 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 14 0.8795 0.6421 0.7936 0.4713 0.6454 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 15 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 16 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 17 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Column 19 0.7645 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 20 0.7645 0.7238 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 21 0.7645 0.7238 0.8353 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 22 0.7645 0.7238 0.8353 0.6780 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 23 0.7645 0.7238 0.8353 0.6780 0.8088 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 24 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 25 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 26 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Column 28 0.2791 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 29 0.2791 0.5064 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 30 0.2791 0.5064 0.7583 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 31 0.2791 0.5064 0.7583 0.3318 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 32 0.2791 0.5064 0.7583 0.3318 0.8737 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 33 0.2791 0.5064 0.7583 0.3318 0.8737 0.1865 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 34 0.2791 0.5064 0.7583 0.3318 0.8737 0.1865 0.3944 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 35 0.2791 0.5064 0.7583 0.3318 0.8737 0.1865 0.3944 0.5057 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 36 0.2791 0.5064 0.7583 0.3318 0.8737 0.1865 0.3944 0.5057 0.0957 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 36 0.2791 0.5064 0.7583 0.3318 0.8737 0.1865 0.3944 0.5057 0.0957 Column 37 0.8633 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 through 27 0.7645 0.7238 0.8353 0.6780 0.8088 0.0410 0.3444 0.1270 0.2434 Columns 28 through 36 0.2791 0.5064 0.7583 0.3318 0.8737 0.1865 0.3944 0.5057 0.0957 Columns 37 through 38 0.8633 0.5883 y = Columns 1 through 9 0.2594 0.5155 0.2883 0.8932 0.5372 0.2814 0.1559 0.7675 0.4409 Columns 10 through 18 0.8795 0.6421 0.7936 0.4713 0.6454 0.3391 0.6118 0.0818 0.9688 Columns 19 th...

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 = [] y = A y = Ao y = Aog y = Aogi y = Aogie y = Aogieg y = Aogiegi y = Aogiegia y = Aogiegiaa y = Aogiegiaaa y = Aogiegiaaay y = Aogiegiaaaya y = Aogiegiaaayaf y = Aogiegiaaayafr y = Aogiegiaaayafrw y = Aogiegiaaayafrwy