Cody

Problem 6. Select every other element of a vector

Solution 2278228

Submitted on 13 May 2020 by Cem Bozkurt
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.7744 0.2801 0.5921 0.1922 0.6610

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.1828 0.7812 0.1770 0.5082 0.1428 0.9865 0.3271 0.9243 0.8057 0.4051 0.8231 0.5044 0.2503 0.8413 0.4811 0.0067 0.7252 0.8934 Columns 19 through 36 0.4421 0.0820 0.4040 0.2486 0.0750 0.9866 0.1215 0.8490 0.7615 0.4655 0.7125 0.1410 0.1654 0.9709 0.9158 0.9952 0.3165 0.4998 Columns 37 through 50 0.0770 0.1388 0.4810 0.3901 0.2564 0.1151 0.5831 0.0519 0.4003 0.8939 0.4167 0.7589 0.3558 0.0657

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!