# How to find the Zero Crossing Rate of a signal?

조회 수: 46 (최근 30일)
Kwaku Owusu . 2021년 1월 19일
답변: Frantz Bouchereau . 2021년 10월 13일
Please, I want to determine the Zero Crossing Rate of an Acoustic Signal. I would be glad if someone could provide me with a code in Matlab to carry out such exercise,

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

### 채택된 답변

Star Strider 2021년 1월 29일
Try this:
t = linspace(0, 5, 500).^3; % Time Vector
s = sin(2*pi*t*0.2); % 10 Hz Sine Curve
zx = find(diff(sign(s))); % Zero-Crossing Indices To ‘t’
for k = 1:numel(zx)
idx_rng = max(zx(k)-1, 1):min(zx(k)+1,numel(t));
tzro(k) = interp1(s(idx_rng), t(idx_rng), 0); % Exact Zero Crossings
end
zx_rate = gradient(tzro); % Calculate Rate
figure
yyaxis left
plot(t, s, '-b')
hold on
plot(tzro, zeros(size(tzro)), 'xr')
hold off
yyaxis right
plot(tzro, zx_rate, 'LineWidth',2)
grid
legend('Signal','Zero-Crossings','Zero-Crossing Rate')
axis('tight')
Once you have the zero-crossings, you can do whatever processing on them that you want.
.

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

### 추가 답변 (2개)

Frantz Bouchereau 2021년 10월 13일
Signal Processing Toolbox in MATLAB R2021b ships a new zerocrossrate function that you can use to find zero crossing rates of a signal.
##### 댓글 수: 0이전 댓글 -1개 표시이전 댓글 -1개 숨기기

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

Mathieu NOE 2021년 1월 19일
hello
i am not sure what a "rate" can be about zero crossing, but at least maybe this code will give you access to zero or whatever threshold value crossing detection
positive slope and negative slope are detected separatly
hope it helps !
##### 댓글 수: 3이전 댓글 2개 표시이전 댓글 2개 숨기기
Kwaku Owusu 2021년 1월 29일
Please, I cannot see the code provided. Thank you.

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

### 카테고리

Help CenterFile Exchange에서 Linear Predictive Coding에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!