Cody

Problem 6. Select every other element of a vector

Solution 2175863

Submitted on 26 Mar 2020
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   Fail
x = rand(1,10); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = 0.4883 0.4387 0.2475 0.5437 0.4363 y = 0.9619 0.8300 0.4151 0.0124 0.4215

Assertion failed.

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

y = Columns 1 through 18 0.5339 0.6230 0.3023 0.5441 0.2798 0.1237 0.0293 0.7116 0.6787 0.7426 0.9620 0.0400 0.6715 0.8062 0.8389 0.2180 0.8520 0.9743 Columns 19 through 36 0.0873 0.2245 0.0990 0.7806 0.4182 0.0535 0.4712 0.0169 0.9222 0.2593 0.6000 0.8567 0.6777 0.3688 0.2756 0.9095 0.3617 0.4053 Columns 37 through 50 0.7529 0.5965 0.4325 0.6660 0.8612 0.0576 0.7802 0.5715 0.1270 0.0026 0.3837 0.2709 0.7508 0.0441 y = Columns 1 through 18 0.9633 0.4679 0.8934 0.9626 0.9020 0.0077 0.4792 0.2984 0.0519 0.5337 0.0167 0.1777 0.0921 0.0043 0.7867 0.3374 0.7510 0.5393 Columns 19 through 36 0.1265 0.9584 0.5645 0.5799 0.1137 0.6899 0.0383 0.8129 0.2832 0.2993 0.1471 0.1705 0.0805 0.0366 0.6125 0.0618 0.6135 0.4532 Columns 37 through 50 0.6559 0.3960 0.3297 0.5932 0.3638 0.8579 0.8000 0.5020 0.7552 0.8146 0.9178 0.7832 0.9374 0.2375

Assertion failed.

3   Fail
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 = 'Aogiegiaaayafrwy' y = 'lntmaonglxfraaa'

Assertion failed.

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!