0

I need to compute frequency of a signal from zero crossing.It's possible to compute to frequency from zero crossing of a signal. Plz anybody help me about this with matlab .

sanjoy saha
  • 1
  • 1
  • 1

2 Answers2

1

From your signal crossing threshold it is fairly straightforward to calculate its period. When you know the period then calculating of corresponding frequency is very simple (its inverse). This answer: enter here answers to similar question.

Black Yasmin
  • 376
  • 3
  • 18
1

I assume you know that this will only work if you need to estimate frequencies in signals next to pure sinusoids, so for this a simple code can be used.

I create a simple sin sampled at 8000hz and frequency at 350hz, lets try get the frenquency using zero crossing method:

Fs = 8000;
f  = 350; %Frequency test
signal= 0.9*sin(2*pi*f/Fs*(0:2048));

%cross = sign(signal(:)); % you can test results using sign function too.
cross(signal==0) = 1;
index= find(diff(cross));
ZC = length(index);
F0_ZC=(ZC * Fs / (2 * (length(signal))))

The result was:

F0_ZC =

  349.4388

Edit

The quick try using @jojek sugestion:

Fs = 8000;
f  = 350; %Frequency test
signal= 0.9*sin(2*pi*f/Fs*(0:2048));
ZCR = sum(abs(diff(sign(signal(:)))))/(2*length(signal));
F0_ZC=(ZCR * length(signal) * Fs) / (2 * (length(signal)))

The result was:

F0_ZC =

  350.4148

Course if you compute the Zero Crossing Rate(ZCR) you can find the frequency using (ZCR * Fs) /2

ederwander
  • 2,038
  • 12
  • 19