Cody

Problem 6. Select every other element of a vector

Solution 944329

Submitted on 28 Aug 2016 by Mashharar Bhuiyan
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.8661 0.1273 0.3324 0.0465 0.4830

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.4234 0.1777 0.7155 0.2429 0.9584 0.6554 0.3688 0.8554 0.8721 Columns 10 through 18 0.5331 0.0096 0.7735 0.0545 0.8257 0.1264 0.6986 0.8811 0.5731 Columns 19 through 27 0.1953 0.4219 0.3390 0.1364 0.8609 0.0172 0.9359 0.6515 0.3995 Columns 28 through 36 0.8331 0.4528 0.8267 0.5090 0.7780 0.6224 0.7875 0.0782 0.7792 Columns 37 through 45 0.2441 0.3045 0.5797 0.0125 0.3011 0.0436 0.9220 0.7038 0.3685 Columns 46 through 50 0.2746 0.6414 0.0759 0.8323 0.2317

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