Cody

Problem 6. Select every other element of a vector

Solution 2129336

Submitted on 15 Feb 2020 by ahmed aghmadi
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.0940 0.6662 0.8627 0.9732 0.7377

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.2303 0.3216 0.2942 0.3186 0.3733 0.1201 0.6882 0.2068 0.7955 0.6347 0.8770 0.6246 0.9513 0.1718 0.8736 0.0648 0.3086 0.7970 Columns 19 through 36 0.0913 0.4789 0.1706 0.7708 0.3691 0.2882 0.8293 0.2203 0.3207 0.6981 0.6787 0.5343 0.1593 0.2132 0.8306 0.7076 0.6938 0.6577 Columns 37 through 50 0.4950 0.9869 0.4339 0.1375 0.5906 0.2476 0.5353 0.6590 0.1538 0.6140 0.9100 0.4059 0.7359 0.3110

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'