Cody

# Problem 6. Select every other element of a vector

Solution 2000398

Submitted on 3 Nov 2019 by Pravallika T
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.1561 y = 0.1561 0.6316 y = 0.1561 0.6316 0.5268 y = 0.1561 0.6316 0.5268 0.3123 y = 0.1561 0.6316 0.5268 0.3123 0.1370

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

y = [] y = 0.5586 y = 0.5586 0.6717 y = 0.5586 0.6717 0.6909 y = 0.5586 0.6717 0.6909 0.5503 y = 0.5586 0.6717 0.6909 0.5503 0.5974 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 y = 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Column 19 0.6283 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 20 0.6283 0.7151 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 21 0.6283 0.7151 0.5099 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 22 0.6283 0.7151 0.5099 0.8174 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 23 0.6283 0.7151 0.5099 0.8174 0.6717 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 24 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 25 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 26 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 27 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 28 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 29 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 30 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 31 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 32 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 33 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 34 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 0.1352 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 35 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 0.1352 0.6213 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 36 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 0.1352 0.6213 0.2239 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 36 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 0.1352 0.6213 0.2239 Column 37 0.1804 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 36 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 0.1352 0.6213 0.2239 Columns 37 through 38 0.1804 0.5198 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 36 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 0.1352 0.6213 0.2239 Columns 37 through 39 0.1804 0.5198 0.2310 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 36 0.6283 0.7151 0.5099 0.8174 0.6717 0.4705 0.2157 0.2676 0.4098 0.4779 0.6485 0.3213 0.2667 0.4068 0.9016 0.1352 0.6213 0.2239 Columns 37 through 40 0.1804 0.5198 0.2310 0.7330 y = Columns 1 through 18 0.5586 0.6717 0.6909 0.5503 0.5974 0.8068 0.7210 0.5450 0.2112 0.9670 0.5486 0.4428 0.7108 0.6449 0.2782 0.3969 0.0722 0.2349 Columns 19 through 36 0.6283 0.7151 ...

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 = 'A' y = 'Ao' y = 'Aog' y = 'Aogi' y = 'Aogie' y = 'Aogieg' y = 'Aogiegi' y = 'Aogiegia' y = 'Aogiegiaa' y = 'Aogiegiaaa' y = 'Aogiegiaaay' y = 'Aogiegiaaaya' y = 'Aogiegiaaayaf' y = 'Aogiegiaaayafr' y = 'Aogiegiaaayafrw' y = 'Aogiegiaaayafrwy'