Cody

# Problem 6. Select every other element of a vector

Solution 2531592

Submitted on 12 Jun 2020 by Huseyin Candas Hepozusta
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))

ans = 0.1097 0.3517 0.6101 0.5159 0.1288

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

ans = Columns 1 through 17 0.6023 0.5300 0.9536 0.5189 0.4081 0.0110 0.6687 0.9032 0.7961 0.3595 0.8454 0.7195 0.7137 0.5908 0.7265 0.4961 0.2076 Columns 18 through 34 0.9250 0.4756 0.4916 0.0443 0.8868 0.4475 0.0185 0.8733 0.8927 0.8028 0.5991 0.0954 0.7187 0.7959 0.6837 0.1767 0.8372 Columns 35 through 50 0.5450 0.6143 0.2985 0.4535 0.5122 0.8216 0.4821 0.2555 0.2208 0.7755 0.5612 0.8795 0.6588 0.5434 0.4498 0.3513

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

ans = 'Aogiegiaaayafrwy'

### Community Treasure Hunt

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

Start Hunting!