Cody

# Problem 6. Select every other element of a vector

Solution 2586085

Submitted on 19 Jun 2020 by Piero Cimule
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.8841 0.6081 0.4156 0.5066 0.2538

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

y = Columns 1 through 18 0.2900 0.0884 0.4380 0.1811 0.2181 0.0195 0.3046 0.9590 0.7776 0.3074 0.7910 0.0464 0.1972 0.9757 0.9877 0.9611 0.1899 0.7956 Columns 19 through 36 0.1265 0.7514 0.3788 0.1950 0.8929 0.4008 0.1360 0.2493 0.0688 0.0588 0.5706 0.0653 0.3613 0.8777 0.3040 0.6996 0.4840 0.5582 Columns 37 through 50 0.2269 0.5201 0.4448 0.9183 0.4252 0.9457 0.6797 0.0187 0.6781 0.4090 0.7038 0.1618 0.5560 0.0599

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'

### Community Treasure Hunt

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

Start Hunting!