You can use logical tests to find the indices between which the signal changes sign. Then you need to interpolate if you want to estimate the cross point more accurately. If linear interpolation is sufficient and your samples are equally spaced in time, you can do this:
x = [-1 -1 2 2 3 -4 -1 1];
upcross = find(x(1:end-1) <= 0 & x(2:end) > 0);
upcross = upcross - x(upcross) ./ (x(upcross+1)-x(upcross));
downcross = find(x(1:end-1) >= 0 & x(2:end) < 0);
downcross = downcross - x(downcross) ./ (x(downcross+1)-x(downcross));
0 件のコメント
サインイン to comment.