Filter löschen
Filter löschen

Calculating cycle frequency of a square wave

12 Ansichten (letzte 30 Tage)
Kieran
Kieran am 1 Sep. 2011
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
  2 Kommentare
Rick Rosson
Rick Rosson am 3 Sep. 2011
Are you using MATLAB or Simulink?
anibal montenegro
anibal montenegro am 2 Feb. 2023
hello. can you share de code please?

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Walter Roberson
Walter Roberson am 3 Sep. 2011
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 am 3 Sep. 2011
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 Kommentar
Walter Roberson
Walter Roberson am 3 Sep. 2011
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.

Melden Sie sich an, um zu kommentieren.


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

Community Treasure Hunt

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

Start Hunting!

Translated by