Cody

# Problem 42922. Zero Cross

Solution 2064149

Submitted on 19 Dec 2019 by Asif Newaz
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 = [1 2 -3 -4 5 6 -7 8 -9 10 11]; n = 6; assert(isequal(Zero_Cross(x),n))

a = 0 -2 0 2 0 -2 2 -2 2 0 n = 6

2   Pass
x = [1 2 -3 ]; n = 1; assert(isequal(Zero_Cross(x),n))

a = 0 -2 n = 1

3   Pass
x = ones(1,100); n = 0; assert(isequal(Zero_Cross(x),n))

a = Columns 1 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 61 through 90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 91 through 99 0 0 0 0 0 0 0 0 0 n = 0

4   Pass
x = [-6.1 -4.2 -1.1 -6 7 -6 -6 -7 -6 -1]; n = 2; assert(isequal(Zero_Cross(x),n))

a = 0 0 0 2 -2 0 0 0 0 n = 2

5   Pass
x = 1 n = 0; assert(isequal(Zero_Cross(x),n))

x = 1 a = [] n = 0

6   Pass
x = ones(1,50) - 25; n = 0; assert(isequal(Zero_Cross(x),n))

a = Columns 1 through 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 31 through 49 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 n = 0

7   Pass
x = 1:50 - 25; n = 0; assert(isequal(Zero_Cross(x),n))

a = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 n = 0

8   Pass
x = [ones(1,50); -ones(1,50)]; x = reshape(x,[1,100]); n = 99; assert(isequal(Zero_Cross(x),n))

a = Columns 1 through 30 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 Columns 31 through 60 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 Columns 61 through 90 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 Columns 91 through 99 -2 2 -2 2 -2 2 -2 2 -2 n = 99

9   Pass
x=[1 -1 0 4 0 -1 -2]; n = 3; assert(isequal(Zero_Cross(x),n))

a = -2 1 1 -1 -1 0 n = 5 x = 1 -1 1 4 1 -1 -2 a = -2 2 0 0 -2 0 n = 3