Cody

# Problem 6. Select every other element of a vector

Solution 1570442

Submitted on 28 Jun 2018 by Nicholas Radziul
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 = [] y = 0.9866 y = 0.9866 0.8610 y = 0.9866 0.8610 0.6424 y = 0.9866 0.8610 0.6424 0.1915 y = 0.9866 0.8610 0.6424 0.1915 0.2527

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

y = [] y = 0.9124 y = 0.9124 0.3420 y = 0.9124 0.3420 0.2727 y = 0.9124 0.3420 0.2727 0.3939 y = 0.9124 0.3420 0.2727 0.3939 0.2251 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 y = 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Column 18 0.0261 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 19 0.0261 0.1450 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 20 0.0261 0.1450 0.2906 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 21 0.0261 0.1450 0.2906 0.6828 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 22 0.0261 0.1450 0.2906 0.6828 0.3070 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 23 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 24 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 25 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 26 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 27 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 28 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 29 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 30 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 31 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 32 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 33 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 34 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 0.1078 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 34 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 0.1078 Column 35 0.0673 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 34 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 0.1078 Columns 35 through 36 0.0673 0.6276 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 34 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 0.1078 Columns 35 through 37 0.0673 0.6276 0.4558 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 34 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 0.1078 Columns 35 through 38 0.0673 0.6276 0.4558 0.8308 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 34 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 0.1078 Columns 35 through 39 0.0673 0.6276 0.4558 0.8308 0.8460 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0.2837 0.1669 0.7794 0.3219 0.9054 Columns 18 through 34 0.0261 0.1450 0.2906 0.6828 0.3070 0.0768 0.9631 0.3762 0.9876 0.2839 0.3659 0.0246 0.9707 0.6615 0.1206 0.7421 0.1078 Columns 35 through 40 0.0673 0.6276 0.4558 0.8308 0.8460 0.2485 y = Columns 1 through 17 0.9124 0.3420 0.2727 0.3939 0.2251 0.2923 0.2725 0.9373 0.0946 0.9018 0.5043 0.9960 0...

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 = [] y = 65 y = 65 111 y = 65 111 103 y = 65 111 103 105 y = 65 111 103 105 101 y = 65 111 103 105 101 103 y = 65 111 103 105 101 103 105 y = 65 111 103 105 101 103 105 97 y = 65 111 103 105 101 103 105 97 97 y = 65 111 103 105 101 103 105 97 97 97 y = 65 111 103 105 101 103 105 97 97 97 121 y = 65 111 103 105 101 103 105 97 97 97 121 97 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 121

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!