Calculating cycle frequency of a square wave

12 次查看(过去 30 天)
Hi,
I am currently analysing a speed signal in the form of square wave. The information I need is the frequency which is in the width of the square wave per cycle.
I need to plot the speed signal in the form of frequency versus time at the same sampling rate as the square wave. At the moment, the only method I can think of is using the zero crossing method and calculate the width between the point of rising slope and falling slope. Then, convert it to frequency.
My main concern is I have got about 5million data points and performing this calculation can be very time consuming. Plus, more than half of my data is affected by noise.
Can anyone please suggest an alternative method of getting the result I need?
Thank you.
Kieran

回答(3 个)

Walter Roberson
Walter Roberson 2011-9-3
zero-crossing can be fast:
transitions = find(diff(X > 0));
Then diff(transitions) should give the half-cycle timing. Sum consecutive pairs to get the points per cycle.

Rick Rosson
Rick Rosson 2011-9-3
You could try transforming the signal from the time-domain to the frequency domain, and then identifying the fundamental frequency and some of the lower order harmonics.
Also, do you need to perform the computation on all 5 million data points? If the signal is stationary, or if it changes relatively slowly, you may be able to estimate the frequency using a relatively small subset of the entire data set.
  1 个评论
Walter Roberson
Walter Roberson 2011-9-3
The poster indicated "I need to plot the speed signal in the form of frequency versus time", so the signal must not be stationary. Not enough information to know how quickly it is changing, though. Also it seems to me that since noise might affect the detection of a crossing, the problem could be complicated by determining whether a change in the timing is noise or a real change.

请先登录,再进行评论。


Rick Rosson
Rick Rosson 2011-9-3
You may want to try using the spectrogram function:
>> doc spectrogram
HTH.
Rick

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by