Cody

# Problem 6. Select every other element of a vector

Solution 1584142

Submitted on 16 Jul 2018 by Deepthi Palagati
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))

a = 0.6729 a = 0.6729 0.5292 a = 0.6729 0.5292 0.9349 a = 0.6729 0.5292 0.9349 0.1784 a = 0.6729 0.5292 0.9349 0.1784 0.1137

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

a = 0.9585 a = 0.9585 0.7683 a = 0.9585 0.7683 0.1114 a = 0.9585 0.7683 0.1114 0.9024 a = 0.9585 0.7683 0.1114 0.9024 0.9189 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 a = 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Column 19 0.9436 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 20 0.9436 0.4640 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 21 0.9436 0.4640 0.5489 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 22 0.9436 0.4640 0.5489 0.9508 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 23 0.9436 0.4640 0.5489 0.9508 0.9889 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 24 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 25 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 26 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 27 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 28 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 29 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 30 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 31 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 32 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 33 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 34 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 0.3074 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 35 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 0.3074 0.4794 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 36 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 0.3074 0.4794 0.0242 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 36 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 0.3074 0.4794 0.0242 Column 37 0.4356 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 36 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 0.3074 0.4794 0.0242 Columns 37 through 38 0.4356 0.7688 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 36 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 0.3074 0.4794 0.0242 Columns 37 through 39 0.4356 0.7688 0.7688 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 36 0.9436 0.4640 0.5489 0.9508 0.9889 0.7874 0.0732 0.8891 0.0223 0.6022 0.0370 0.5021 0.6612 0.9903 0.5753 0.3074 0.4794 0.0242 Columns 37 through 40 0.4356 0.7688 0.7688 0.5130 a = Columns 1 through 18 0.9585 0.7683 0.1114 0.9024 0.9189 0.7398 0.9653 0.7791 0.1764 0.3695 0.4341 0.9131 0.3119 0.8767 0.9276 0.0387 0.0611 0.8177 Columns 19 through 36 0.9436 0.4640 0.5489 0.95...

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))

a = 'A' a = 'Ao' a = 'Aog' a = 'Aogi' a = 'Aogie' a = 'Aogieg' a = 'Aogiegi' a = 'Aogiegia' a = 'Aogiegiaa' a = 'Aogiegiaaa' a = 'Aogiegiaaay' a = 'Aogiegiaaaya' a = 'Aogiegiaaayaf' a = 'Aogiegiaaayafr' a = 'Aogiegiaaayafrw' a = 'Aogiegiaaayafrwy'