Cody

Problem 6. Select every other element of a vector

Solution 2025172

Submitted on 17 Nov 2019 by Vaibhav Shende
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.4804 0.3900 0.2682 0.2309 0.4935

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.2399 0.3190 0.9598 0.6347 0.6619 0.8344 0.8112 0.4885 0.3510 0.3655 0.8497 0.5068 0.3653 0.3120 0.3847 0.5639 0.3091 Columns 18 through 34 0.3772 0.1632 0.9091 0.2486 0.1299 0.0695 0.6747 0.3471 0.3101 0.5333 0.0377 0.9190 0.0860 0.9146 0.8830 0.0761 0.7261 Columns 35 through 50 0.5247 0.5825 0.8954 0.2854 0.5202 0.4060 0.5022 0.2510 0.0724 0.9926 0.2237 0.0692 0.7605 0.7454 0.9143 0.4825

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'