Cody

# Problem 6. Select every other element of a vector

Solution 775495

Submitted on 10 Nov 2015 by vahid simintan
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.8101 0.8597 0.7097 0.8956 0.3286

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.4089 0.9501 0.7921 0.6825 0.3227 0.7064 0.0989 0.2511 0.8106 Columns 10 through 18 0.8712 0.9624 0.4003 0.8154 0.2415 0.5011 0.4901 0.2791 0.0628 Columns 19 through 27 0.5824 0.6525 0.2709 0.9994 0.3367 0.8281 0.7940 0.1146 0.5910 Columns 28 through 36 0.7337 0.8750 0.5351 0.8541 0.4391 0.3359 0.3738 0.6052 0.9984 Columns 37 through 45 0.1454 0.9989 0.5806 0.2709 0.9832 0.7186 0.7969 0.3241 0.6135 Columns 46 through 50 0.6360 0.6849 0.7654 0.0190 0.0520

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!