Cody

# Problem 6. Select every other element of a vector

Solution 1861840

Submitted on 30 Jun 2019
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   Fail
x = rand(1,10); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

final_size = 2

Undefined function or variable 'y'. Error in everyOther (line 4) y(i:end) = x(i:2:end) Error in Test1 (line 2) actual = everyOther(x);

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

final_size = 2

Undefined function or variable 'y'. Error in everyOther (line 4) y(i:end) = x(i:2:end) Error in Test2 (line 2) actual = everyOther(x);

3   Fail
x = ['A' 'long' 'time' 'ago' 'in' 'a' 'galaxy' 'far' 'far' 'away']; actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

final_size = 2

Undefined function or variable 'y'. Error in everyOther (line 4) y(i:end) = x(i:2:end) Error in Test3 (line 2) actual = everyOther(x);

### Community Treasure Hunt

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

Start Hunting!