Cody

Problem 6. Select every other element of a vector

Solution 977896

Submitted on 21 Sep 2016 by Arthur Papazian
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))

r = 1 c = 10 y = [] y = 0.9192 y = 0.9192 0.6340 y = 0.9192 0.6340 0.6232 y = 0.9192 0.6340 0.6232 0.3890 y = 0.9192 0.6340 0.6232 0.3890 0.4742

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

r = 1 c = 100 y = [] y = 0.7610 y = 0.7610 0.6316 y = 0.7610 0.6316 0.9259 y = 0.7610 0.6316 0.9259 0.6348 y = 0.7610 0.6316 0.9259 0.6348 0.9084 y = 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 y = 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 y = 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 y = 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Column 10 0.4259 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 11 0.4259 0.2362 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 12 0.4259 0.2362 0.0156 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 13 0.4259 0.2362 0.0156 0.9908 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 14 0.4259 0.2362 0.0156 0.9908 0.2346 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 15 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 16 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 17 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Column 19 0.9023 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 20 0.9023 0.7711 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 21 0.9023 0.7711 0.7304 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 22 0.9023 0.7711 0.7304 0.8996 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 23 0.9023 0.7711 0.7304 0.8996 0.2026 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 24 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 25 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 26 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Column 28 0.3579 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 29 0.3579 0.9070 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 30 0.3579 0.9070 0.2321 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 31 0.3579 0.9070 0.2321 0.7202 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 32 0.3579 0.9070 0.2321 0.7202 0.7831 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 33 0.3579 0.9070 0.2321 0.7202 0.7831 0.8492 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 34 0.3579 0.9070 0.2321 0.7202 0.7831 0.8492 0.7408 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 35 0.3579 0.9070 0.2321 0.7202 0.7831 0.8492 0.7408 0.1513 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 36 0.3579 0.9070 0.2321 0.7202 0.7831 0.8492 0.7408 0.1513 0.7192 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 36 0.3579 0.9070 0.2321 0.7202 0.7831 0.8492 0.7408 0.1513 0.7192 Column 37 0.4778 y = Columns 1 through 9 0.7610 0.6316 0.9259 0.6348 0.9084 0.6503 0.0676 0.2414 0.7865 Columns 10 through 18 0.4259 0.2362 0.0156 0.9908 0.2346 0.6298 0.5633 0.6568 0.1048 Columns 19 through 27 0.9023 0.7711 0.7304 0.8996 0.2026 0.9448 0.7940 0.5964 0.8163 Columns 28 through 36 0.3579 0.9070 0.2321 0.7202 0.7831 0.8492 0.7408 0.1513 0.7192...

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

r = 1 c = 31 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

Suggested Problems

More from this Author95

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!