Cody

# Problem 6. Select every other element of a vector

Solution 224981

Submitted on 28 Mar 2013 by Robert Weinberg
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.0225 y = 0.0225 0.3127 y = 0.0225 0.3127 0.1788 y = 0.0225 0.3127 0.1788 0.0942 y = 0.0225 0.3127 0.1788 0.0942 0.4709

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

y = 0.6999 y = 0.6999 0.0336 y = 0.6999 0.0336 0.3196 y = 0.6999 0.0336 0.3196 0.6544 y = 0.6999 0.0336 0.3196 0.6544 0.8200 y = 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 y = 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 y = 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 y = 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 y = 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Column 11 0.2810 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 12 0.2810 0.5271 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 13 0.2810 0.5271 0.8754 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 14 0.2810 0.5271 0.8754 0.9436 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 15 0.2810 0.5271 0.8754 0.9436 0.9577 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 16 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 17 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 18 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 19 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Column 21 0.7805 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 22 0.7805 0.0067 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 23 0.7805 0.0067 0.3868 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 24 0.7805 0.0067 0.3868 0.0012 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 25 0.7805 0.0067 0.3868 0.0012 0.4243 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 26 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 27 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 28 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 29 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Column 31 0.6074 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 32 0.6074 0.7384 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 33 0.6074 0.7384 0.9174 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 34 0.6074 0.7384 0.9174 0.7655 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 35 0.6074 0.7384 0.9174 0.7655 0.2875 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 36 0.6074 0.7384 0.9174 0.7655 0.2875 0.5762 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 37 0.6074 0.7384 0.9174 0.7655 0.2875 0.5762 0.5466 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 38 0.6074 0.7384 0.9174 0.7655 0.2875 0.5762 0.5466 0.6444 y = Columns 1 through 10 0.6999 0.0336 0.3196 0.6544 0.8200 0.9686 0.3251 0.6110 0.4235 0.2665 Columns 11 through 20 0.2810 0.5271 0.8754 0.9436 0.9577 0.6761 0.6718 0.0680 0.2240 0.8444 Columns 21 through 30 0.7805 0.0067 0.3868 0.0012 0.4243 0.7702 0.7847 0.0358 0.7218 0.1527 Columns 31 through 39 0.6074 0.7384 0.9174 0.765...

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