# command or code for detecting zero crossing points in a signal

조회 수: 34(최근 30일)
pradeep kumar manelli 2015년 12월 29일
답변: David Young 2015년 12월 29일
please suggest any command or code for detecting zero crossing points in a signal

댓글을 달려면 로그인하십시오.

### 답변(1개)

David Young 2015년 12월 29일
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:
% test signal
x = [-1 -1 2 2 3 -4 -1 1];
% upward zero-crossings to nearest time step
upcross = find(x(1:end-1) <= 0 & x(2:end) > 0);
% interpolate
upcross = upcross - x(upcross) ./ (x(upcross+1)-x(upcross));
% downward zero-crossings
downcross = find(x(1:end-1) >= 0 & x(2:end) < 0);
downcross = downcross - x(downcross) ./ (x(downcross+1)-x(downcross));

댓글을 달려면 로그인하십시오.

### 범주

Find more on Signal Operations in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by