필터 지우기
필터 지우기

Calculating cycle frequency of a square wave

조회 수: 12 (최근 30일)
Kieran
Kieran 2011년 9월 1일
댓글: anibal montenegro 2023년 2월 2일
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
Rick Rosson
Rick Rosson 2011년 9월 3일
Are you using MATLAB or Simulink?
anibal montenegro
anibal montenegro 2023년 2월 2일
hello. can you share de code please?

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

답변 (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