Cody

Problem 6. Select every other element of a vector

Solution 2289731

Submitted on 17 May 2020 by Edward Vaughn
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.5041 0.4378 0.7100 0.4495 0.0400

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.8615 0.4793 0.9066 0.8615 0.2500 0.1456 0.5274 0.2305 0.8686 0.3857 0.5802 0.7591 0.0154 0.4928 0.5019 0.8444 0.8723 Columns 18 through 34 0.0519 0.3952 0.1694 0.8335 0.5391 0.8498 0.7887 0.9816 0.6945 0.5145 0.1539 0.1108 0.0461 0.1218 0.5331 0.6628 0.5156 Columns 35 through 50 0.0588 0.0487 0.0624 0.8465 0.9688 0.1300 0.3676 0.3596 0.4001 0.9505 0.5322 0.4313 0.2580 0.0541 0.8574 0.8819

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