Cody

# Problem 6. Select every other element of a vector

Solution 1362382

Submitted on 29 Nov 2017 by cruxjello Late
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.7950 0.4255 0.3618 0.0022 0.5862 0.5453 0.2249 0.2126 0.6191 0.4501 y = 0.7950 0.4255 0.3618 0.0022 0.5862

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

y = Columns 1 through 17 0.8718 0.8292 0.9330 0.7168 0.3030 0.3812 0.3877 0.5817 0.1266 0.5109 0.5226 0.5578 0.8498 0.2103 0.7181 0.4694 0.0085 0.1122 0.8104 0.0496 0.0683 0.6694 0.0800 0.5694 0.0003 0.8126 0.0556 0.9103 0.9412 0.9621 0.4195 0.1050 0.0890 0.8124 Columns 18 through 34 0.9732 0.5616 0.9862 0.7059 0.1470 0.3967 0.7760 0.5787 0.7063 0.4891 0.4764 0.0112 0.2470 0.4183 0.0892 0.0360 0.4467 0.2470 0.0246 0.4436 0.2681 0.4320 0.4535 0.9766 0.6986 0.5995 0.0066 0.5179 0.6183 0.2901 0.5291 0.0340 0.2251 0.3573 Columns 35 through 50 0.3312 0.1091 0.0697 0.2903 0.1638 0.7052 0.4430 0.3178 0.0265 0.5067 0.4376 0.7514 0.6344 0.5815 0.1417 0.4454 0.0443 0.3732 0.4224 0.0906 0.1527 0.7124 0.2438 0.0613 0.8425 0.9667 0.7173 0.6514 0.4309 0.6549 0.5834 0.5443 y = Columns 1 through 17 0.8718 0.8292 0.9330 0.7168 0.3030 0.3812 0.3877 0.5817 0.1266 0.5109 0.5226 0.5578 0.8498 0.2103 0.7181 0.4694 0.0085 Columns 18 through 34 0.9732 0.5616 0.9862 0.7059 0.1470 0.3967 0.7760 0.5787 0.7063 0.4891 0.4764 0.0112 0.2470 0.4183 0.0892 0.0360 0.4467 Columns 35 through 50 0.3312 0.1091 0.0697 0.2903 0.1638 0.7052 0.4430 0.3178 0.0265 0.5067 0.4376 0.7514 0.6344 0.5815 0.1417 0.4454

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

x = 'Alongtimeagoinagalaxyfarfaraway' y = 2×16 char array 'Aogiegiaaayafrwy' 'lntmaonglxfraaa' y = 'Aogiegiaaayafrwy'