Cody

Problem 6. Select every other element of a vector

Solution 1064636

Submitted on 28 Nov 2016 by suin kim
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.9980 0.6146 0.2401 0.4818 0.9854

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

y = Columns 1 through 9 0.0603 0.3120 0.9573 0.3303 0.2184 0.3571 0.6965 0.1674 0.7981 Columns 10 through 18 0.9904 0.2469 0.6217 0.0471 0.0820 0.4236 0.6673 0.9723 0.9166 Columns 19 through 27 0.1600 0.0884 0.0263 0.0373 0.3054 0.3670 0.2276 0.7502 0.0714 Columns 28 through 36 0.1363 0.2240 0.0802 0.1882 0.5596 0.3636 0.3455 0.8866 0.8160 Columns 37 through 45 0.1580 0.3433 0.3456 0.2685 0.6727 0.6319 0.1542 0.5926 0.8399 Columns 46 through 50 0.6755 0.1520 0.6512 0.6871 0.6185

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

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!