Cody

# Problem 6. Select every other element of a vector

Solution 265356

Submitted on 21 Jun 2013 by Sarah
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.9666 0.4453 0.9905 0.7943 0.4886 0.1306 0.2122 0.8311 0.3238 y = 0.9666 0.4453 0.7943 0.4886 0.1306 0.2122 0.8311 0.3238 y = 0.9666 0.4453 0.7943 0.1306 0.2122 0.8311 0.3238 y = 0.9666 0.4453 0.7943 0.1306 0.8311 0.3238 y = 0.9666 0.4453 0.7943 0.1306 0.8311

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

y = Columns 1 through 10 0.7388 0.7315 0.0537 0.7144 0.1217 0.9840 0.5931 0.2695 0.4320 0.9305 Columns 11 through 20 0.5079 0.0641 0.6591 0.4492 0.1472 0.7752 0.5313 0.0879 0.9005 0.8682 Columns 21 through 30 0.0563 0.6401 0.8893 0.3477 0.6667 0.4545 0.4469 0.0170 0.8614 0.9378 Columns 31 through 40 0.4788 0.5698 0.9928 0.4041 0.2198 0.8665 0.6890 0.1715 0.0090 0.1691 Columns 41 through 50 0.2064 0.9016 0.7091 0.1319 0.4252 0.6614 0.3224 0.5974 0.2106 0.1896 Columns 51 through 60 0.2083 0.7133 0.2527 0.2700 0.4818 0.2207 0.3547 0.6377 0.7498 0.4924 Columns 61 through 70 0.6174 0.3195 0.3025 0.1418 0.8443 0.2882 0.9088 0.1132 0.6139 0.2839 Columns 71 through 80 0.5081 0.5389 0.0522 0.4371 0.2187 0.9183 0.6915 0.1159 0.3596 0.3061 Columns 81 through 90 0.3022 0.5614 0.7961 0.4699 0.7912 0.4188 0.7395 0.3575 0.9498 0.7501 Columns 91 through 99 0.0196 0.7552 0.9118 0.3478 0.0713 0.8551 0.0944 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.1217 0.9840 0.5931 0.2695 0.4320 0.9305 0.5079 Columns 11 through 20 0.0641 0.6591 0.4492 0.1472 0.7752 0.5313 0.0879 0.9005 0.8682 0.0563 Columns 21 through 30 0.6401 0.8893 0.3477 0.6667 0.4545 0.4469 0.0170 0.8614 0.9378 0.4788 Columns 31 through 40 0.5698 0.9928 0.4041 0.2198 0.8665 0.6890 0.1715 0.0090 0.1691 0.2064 Columns 41 through 50 0.9016 0.7091 0.1319 0.4252 0.6614 0.3224 0.5974 0.2106 0.1896 0.2083 Columns 51 through 60 0.7133 0.2527 0.2700 0.4818 0.2207 0.3547 0.6377 0.7498 0.4924 0.6174 Columns 61 through 70 0.3195 0.3025 0.1418 0.8443 0.2882 0.9088 0.1132 0.6139 0.2839 0.5081 Columns 71 through 80 0.5389 0.0522 0.4371 0.2187 0.9183 0.6915 0.1159 0.3596 0.3061 0.3022 Columns 81 through 90 0.5614 0.7961 0.4699 0.7912 0.4188 0.7395 0.3575 0.9498 0.7501 0.0196 Columns 91 through 98 0.7552 0.9118 0.3478 0.0713 0.8551 0.0944 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.9840 0.5931 0.2695 0.4320 0.9305 0.5079 0.0641 Columns 11 through 20 0.6591 0.4492 0.1472 0.7752 0.5313 0.0879 0.9005 0.8682 0.0563 0.6401 Columns 21 through 30 0.8893 0.3477 0.6667 0.4545 0.4469 0.0170 0.8614 0.9378 0.4788 0.5698 Columns 31 through 40 0.9928 0.4041 0.2198 0.8665 0.6890 0.1715 0.0090 0.1691 0.2064 0.9016 Columns 41 through 50 0.7091 0.1319 0.4252 0.6614 0.3224 0.5974 0.2106 0.1896 0.2083 0.7133 Columns 51 through 60 0.2527 0.2700 0.4818 0.2207 0.3547 0.6377 0.7498 0.4924 0.6174 0.3195 Columns 61 through 70 0.3025 0.1418 0.8443 0.2882 0.9088 0.1132 0.6139 0.2839 0.5081 0.5389 Columns 71 through 80 0.0522 0.4371 0.2187 0.9183 0.6915 0.1159 0.3596 0.3061 0.3022 0.5614 Columns 81 through 90 0.7961 0.4699 0.7912 0.4188 0.7395 0.3575 0.9498 0.7501 0.0196 0.7552 Columns 91 through 97 0.9118 0.3478 0.0713 0.8551 0.0944 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.9840 0.2695 0.4320 0.9305 0.5079 0.0641 0.6591 Columns 11 through 20 0.4492 0.1472 0.7752 0.5313 0.0879 0.9005 0.8682 0.0563 0.6401 0.8893 Columns 21 through 30 0.3477 0.6667 0.4545 0.4469 0.0170 0.8614 0.9378 0.4788 0.5698 0.9928 Columns 31 through 40 0.4041 0.2198 0.8665 0.6890 0.1715 0.0090 0.1691 0.2064 0.9016 0.7091 Columns 41 through 50 0.1319 0.4252 0.6614 0.3224 0.5974 0.2106 0.1896 0.2083 0.7133 0.2527 Columns 51 through 60 0.2700 0.4818 0.2207 0.3547 0.6377 0.7498 0.4924 0.6174 0.3195 0.3025 Columns 61 through 70 0.1418 0.8443 0.2882 0.9088 0.1132 0.6139 0.2839 0.5081 0.5389 0.0522 Columns 71 through 80 0.4371 0.2187 0.9183 0.6915 0.1159 0.3596 0.3061 0.3022 0.5614 0.7961 Columns 81 through 90 0.4699 0.7912 0.4188 0.7395 0.3575 0.9498 0.7501 0.0196 0.7552 0.9118 Columns 91 through 96 0.3478 0.0713 0.8551 0.0944 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.9840 0.2695 0.9305 0.5079 0.0641 0.6591 0.4492 Columns 11 through 20 0.1472 0.7752 0.5313 0.0879 0.9005 0.8682 0.0563 0.6401 0.8893 0.3477 Columns 21 through 30 0.6667 0.4545 0.4469 0.0170 0.8614 0.9378 0.4788 0.5698 0.9928 0.4041 Columns 31 through 40 0.2198 0.8665 0.6890 0.1715 0.0090 0.1691 0.2064 0.9016 0.7091 0.1319 Columns 41 through 50 0.4252 0.6614 0.3224 0.5974 0.2106 0.1896 0.2083 0.7133 0.2527 0.2700 Columns 51 through 60 0.4818 0.2207 0.3547 0.6377 0.7498 0.4924 0.6174 0.3195 0.3025 0.1418 Columns 61 through 70 0.8443 0.2882 0.9088 0.1132 0.6139 0.2839 0.5081 0.5389 0.0522 0.4371 Columns 71 through 80 0.2187 0.9183 0.6915 0.1159 0.3596 0.3061 0.3022 0.5614 0.7961 0.4699 Columns 81 through 90 0.7912 0.4188 0.7395 0.3575 0.9498 0.7501 0.0196 0.7552 0.9118 0.3478 Columns 91 through 95 0.0713 0.8551 0.0944 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.9840 0.2695 0.9305 0.0641 0.6591 0.4492 0.1472 Columns 11 through 20 0.7752 0.5313 0.0879 0.9005 0.8682 0.0563 0.6401 0.8893 0.3477 0.6667 Columns 21 through 30 0.4545 0.4469 0.0170 0.8614 0.9378 0.4788 0.5698 0.9928 0.4041 0.2198 Columns 31 through 40 0.8665 0.6890 0.1715 0.0090 0.1691 0.2064 0.9016 0.7091 0.1319 0.4252 Columns 41 through 50 0.6614 0.3224 0.5974 0.2106 0.1896 0.2083 0.7133 0.2527 0.2700 0.4818 Columns 51 through 60 0.2207 0.3547 0.6377 0.7498 0.4924 0.6174 0.3195 0.3025 0.1418 0.8443 Columns 61 through 70 0.2882 0.9088 0.1132 0.6139 0.2839 0.5081 0.5389 0.0522 0.4371 0.2187 Columns 71 through 80 0.9183 0.6915 0.1159 0.3596 0.3061 0.3022 0.5614 0.7961 0.4699 0.7912 Columns 81 through 90 0.4188 0.7395 0.3575 0.9498 0.7501 0.0196 0.7552 0.9118 0.3478 0.0713 Columns 91 through 94 0.8551 0.0944 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.9840 0.2695 0.9305 0.0641 0.4492 0.1472 0.7752 Columns 11 through 20 0.5313 0.0879 0.9005 0.8682 0.0563 0.6401 0.8893 0.3477 0.6667 0.4545 Columns 21 through 30 0.4469 0.0170 0.8614 0.9378 0.4788 0.5698 0.9928 0.4041 0.2198 0.8665 Columns 31 through 40 0.6890 0.1715 0.0090 0.1691 0.2064 0.9016 0.7091 0.1319 0.4252 0.6614 Columns 41 through 50 0.3224 0.5974 0.2106 0.1896 0.2083 0.7133 0.2527 0.2700 0.4818 0.2207 Columns 51 through 60 0.3547 0.6377 0.7498 0.4924 0.6174 0.3195 0.3025 0.1418 0.8443 0.2882 Columns 61 through 70 0.9088 0.1132 0.6139 0.2839 0.5081 0.5389 0.0522 0.4371 0.2187 0.9183 Columns 71 through 80 0.6915 0.1159 0.3596 0.3061 0.3022 0.5614 0.7961 0.4699 0.7912 0.4188 Columns 81 through 90 0.7395 0.3575 0.9498 0.7501 0.0196 0.7552 0.9118 0.3478 0.0713 0.8551 Columns 91 through 93 0.0944 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.9840 0.2695 0.9305 0.0641 0.4492 0.7752 0.5313 Columns 11 through 20 0.0879 0.9005 0.8682 0.0563 0.6401 0.8893 0.3477 0.6667 0.4545 0.4469 Columns 21 through 30 0.0170 0.8614 0.9378 0.4788 0.5698 0.9928 0.4041 0.2198 0.8665 0.6890 Columns 31 through 40 0.1715 0.0090 0.1691 0.2064 0.9016 0.7091 0.1319 0.4252 0.6614 0.3224 Columns 41 through 50 0.5974 0.2106 0.1896 0.2083 0.7133 0.2527 0.2700 0.4818 0.2207 0.3547 Columns 51 through 60 0.6377 0.7498 0.4924 0.6174 0.3195 0.3025 0.1418 0.8443 0.2882 0.9088 Columns 61 through 70 0.1132 0.6139 0.2839 0.5081 0.5389 0.0522 0.4371 0.2187 0.9183 0.6915 Columns 71 through 80 0.1159 0.3596 0.3061 0.3022 0.5614 0.7961 0.4699 0.7912 0.4188 0.7395 Columns 81 through 90 0.3575 0.9498 0.7501 0.0196 0.7552 0.9118 0.3478 0.0713 0.8551 0.0944 Columns 91 through 92 0.5496 0.9155 y = Columns 1 through 10 0.7388 0.7315 0.7144 0.9840 0.2695 0.9305 0.0641 0.4492 0.7752 0.0879 Columns 11 through 20 0.9005 0.8682 0.0563 0.6401 0.8893 0.3477 0.6667 0.4545 0.4469 0.0170 Columns 21 through 30 0.8614 0.9378 0.4788 0.5698 0.9928 0.40...

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 = Aongtimeagoinagalaxyfarfaraway y = Aogtimeagoinagalaxyfarfaraway y = Aogimeagoinagalaxyfarfaraway y = Aogieagoinagalaxyfarfaraway y = Aogiegoinagalaxyfarfaraway y = Aogieginagalaxyfarfaraway y = Aogiegiagalaxyfarfaraway y = Aogiegiaalaxyfarfaraway y = Aogiegiaaaxyfarfaraway y = Aogiegiaaayfarfaraway y = Aogiegiaaayarfaraway y = Aogiegiaaayafaraway y = Aogiegiaaayafraway y = Aogiegiaaayafrway y = Aogiegiaaayafrwy