Cody

# Problem 6. Select every other element of a vector

Solution 2136467

Submitted on 21 Feb 2020
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))

Index in position 2 is invalid. Array indices must be positive integers or logical values. Error in everyOther (line 3) y = x(2*n+1,n); 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))

Index in position 2 is invalid. Array indices must be positive integers or logical values. Error in everyOther (line 3) y = x(2*n+1,n); 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))

Error using : For colon operator with char operands, first and last operands must be char. Error in everyOther (line 2) for n=0:x; Error in Test3 (line 2) actual = everyOther(x);