Cody

Problem 6. Select every other element of a vector

Solution 1228346

Submitted on 10 Jul 2017 by Dustin Jones
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.5837 0.7892 0.5442 0.6950 0.3819

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

y = Columns 1 through 18 0.3783 0.0121 0.2771 0.5309 0.5343 0.7352 0.1217 0.2407 0.0085 0.5750 0.8947 0.7518 0.8266 0.7953 0.0382 0.8334 0.0041 0.8526 Columns 19 through 36 0.1939 0.3913 0.9306 0.5823 0.7914 0.2838 0.1431 0.8223 0.3102 0.7083 0.1558 0.1311 0.2128 0.9928 0.9605 0.0829 0.3328 0.7380 Columns 37 through 50 0.3412 0.4990 0.4313 0.8938 0.3789 0.5963 0.9684 0.5731 0.3946 0.3805 0.6150 0.5144 0.7902 0.0983

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'