Cody

# Problem 42922. Zero Cross

Solution 1586530

Submitted on 18 Jul 2018 by Ankith Rathod
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))

pos = 1 n = 1 pos = 0 n = 2 pos = 1 n = 3 pos = 0 n = 4 pos = 1 n = 5 pos = 0 n = 6 pos = 1

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

pos = 1 n = 1 pos = 0

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

pos = 1

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

pos = 0 n = 1 pos = 1 n = 2 pos = 0

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

x = 1 pos = 1

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

pos = 0

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

pos = 1

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

pos = 1 n = 1 pos = 0 n = 2 pos = 1 n = 3 pos = 0 n = 4 pos = 1 n = 5 pos = 0 n = 6 pos = 1 n = 7 pos = 0 n = 8 pos = 1 n = 9 pos = 0 n = 10 pos = 1 n = 11 pos = 0 n = 12 pos = 1 n = 13 pos = 0 n = 14 pos = 1 n = 15 pos = 0 n = 16 pos = 1 n = 17 pos = 0 n = 18 pos = 1 n = 19 pos = 0 n = 20 pos = 1 n = 21 pos = 0 n = 22 pos = 1 n = 23 pos = 0 n = 24 pos = 1 n = 25 pos = 0 n = 26 pos = 1 n = 27 pos = 0 n = 28 pos = 1 n = 29 pos = 0 n = 30 pos = 1 n = 31 pos = 0 n = 32 pos = 1 n = 33 pos = 0 n = 34 pos = 1 n = 35 pos = 0 n = 36 pos = 1 n = 37 pos = 0 n = 38 pos = 1 n = 39 pos = 0 n = 40 pos = 1 n = 41 pos = 0 n = 42 pos = 1 n = 43 pos = 0 n = 44 pos = 1 n = 45 pos = 0 n = 46 pos = 1 n = 47 pos = 0 n = 48 pos = 1 n = 49 pos = 0 n = 50 pos = 1 n = 51 pos = 0 n = 52 pos = 1 n = 53 pos = 0 n = 54 pos = 1 n = 55 pos = 0 n = 56 pos = 1 n = 57 pos = 0 n = 58 pos = 1 n = 59 pos = 0 n = 60 pos = 1 n = 61 pos = 0 n = 62 pos = 1 n = 63 pos = 0 n = 64 pos = 1 n = 65 pos = 0 n = 66 pos = 1 n = 67 pos = 0 n = 68 pos = 1 n = 69 pos = 0 n = 70 pos = 1 n = 71 pos = 0 n = 72 pos = 1 n = 73 pos = 0 n = 74 pos = 1 n = 75 pos = 0 n = 76 pos = 1 n = 77 pos = 0 n = 78 pos = 1 n = 79 pos = 0 n = 80 pos = 1 n = 81 pos = 0 n = 82 pos = 1 n = 83 pos = 0 n = 84 pos = 1 n = 85 pos = 0 n = 86 pos = 1 n = 87 pos = 0 n = 88 pos = 1 n = 89 pos = 0 n = 90 pos = 1 n = 91 pos = 0 n = 92 pos = 1 n = 93 pos = 0 n = 94 pos = 1 n = 95 pos = 0 n = 96 pos = 1 n = 97 pos = 0 n = 98 pos = 1 n = 99 pos = 0