I have a sine wave whose frequency is changing in irergular intervals from 50HZ to 55HZ and back to 50HZ.i need to extract the frequency information from the sin wave I need to plot the frequency vs time in a graph..

4 views (last 30 days)
Hi, I have a sin wave whose frequency is changing in irregular intervals from 0 to 10 sec the frequency is 50 HZ sec.From 10 sec to 25 HZ the frequency is 55HZ, its again becoming 50HZ from 25 sec to 30 sec. I need to extract the frequency information (not spectrum analysis) from sin wave itself,that from what time to till what time 50 HZ,55 HZ is persisting and at what time onwards 50 Hz is again coming and persisting,just a frequency (y axis) vs time(x axis) plot, means suppose a 50 Hz frequency is exciting from 0 to 10 sec i need to plot a straight line in 50 HZ till 10 sec and if the frequency is changing to 55 HZ from 10 sec to 25 sec i need to see that change in my graph and again going back to 55 HZ at 25 sec.i tried lots of methodS..Its showing error, and its not plotting correctly, Can any one help me in this issue?

Accepted Answer

Wayne King
Wayne King on 29 Jul 2012
In this simple example, you can use the short-time Fourier transform to do this. You're really after something called the instantaneous frequency, which is not a trivial thing to estimate in most cases.
Fs = 1000;
t = 0:1/Fs:30-(1/Fs);
x = cos(2*pi*50*t).*(t<=10)+cos(2*pi*55*t).*(t>10 & t<=25)+...
cos(2*pi*50*t).*(t>25 & t<30);
plot(t,x)
[y,f,T,p] = spectrogram(x,250,200,200,Fs);
preduced = p(11:12,:);
subplot(211)
plot(T,preduced(1,:))
title('50-Hz Component')
subplot(212)
plot(T,preduced(2,:))
title('55-Hz Component');
xlabel('Seconds')
  4 Comments
mskumarsajeesh mskumar
mskumarsajeesh mskumar on 31 Jul 2012
Edited: mskumarsajeesh mskumar on 31 Jul 2012
Thanks for correcting me.What i am doing is i have a signal which contains harmonics also whose fundamental frequency is varying in irregular time intervals, I eliminated OR filtered the harmonics,now my signal is in fundamental frequency range that only i know. My fundamental is 50 Hz and its varying between 55 Hz and back to 50 Hz in irregular time intervals, i need to extract the fundamental frequency and also the change in the frequency and i have to display that in frequency(y axis) and time(x axis), Mr.WAYNE answered that we can use short Fourier transform to detect and to plot that change, I tried the code its really working. But he said its not trivial to estimate instantaneous frequency by using the short Fourier transform. If use the short Fourier transform in real world situation to detect the change in the fundamental frequency , will it give the change in frequency accurately?. & Will there be any tracking error? that's what i am asking .Expecting the reply. Can any one help me in this issue?
Bjorn Gustavsson
Bjorn Gustavsson on 31 Jul 2012
Well time-frequency analysis is not my core field of work, so my expertise in the more technical details is vague, but there is a good matlab toolbox for time-frequency analysis (with good documentation!) that I've used:
There they describe the hows and ifs about instantaneous frequency. In short w(t) is defined as the time derivative of the instantaneous phase. The instantaneous phase (and amplitude) you get by way of the Hilbert transform. But have a look at the time-frequency toolbox.
HTH,

Sign in to comment.

More Answers (0)

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!