# Fourier transform of oscillating signals

Dear All,
I have a time series vector of two measured oscillating signals, say denoted by cc (controlled to periodic behaviour) and c (chaotic
behaviour). I am sampling both the signals at time intervals of every 0.0001 hours (0.36 secs).
I wish to find out the following:     1. the power spectrum to show the period of oscillations of the respective signal     2. calculate the time period of the signal when the controlled signal is of period 1 osciilations (limit cycle), period 2 or higher periods     3. time instants when it crosses the mean value of the signal
I think the best way to do it would be to use fourier transforms of the signal. I am using MATLAB 7.1, and after reading the documentation files, I have come up with the following codes. I am not sure if its correct or not. I think I am
calculating the power spectrum correctly but the time period is wrong. The code is mentioned below.
********************************************* Yftc = fft(cc); % Calculates the fourier transform of the controlled signal Yft = fft(c); % Calculates the fourier transform of the chaotic signal Nc = length(Yftc); N = length(Yft); Yftc(1) = []; Yft(1) = []; powerc = abs(Yftc(1:Nc/2)).^2; power = abs(Yft(1:N/2)).^2; nyquistc = 1/2; nyquist = 1/2; freqc = (1:Nc/2)/(Nc/2)*nyquistc; freq = (1:N/2)/(N/2)*nyquist; periodc = 1./freqc; period = 1./freq;
[mpc,indexc] = max(powerc); % Calculates the maximum power periodc(indexc) % Finds the time period of oscillations of the maximum frequency component
************************************************
I would be grateful if someone is able to mention any flaws in the coding or any better days to do it. Thanks for any suggestions or replies/criticisms/brickbats.
Cheers Ankur
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Ankur,
First, it would be good to separate the structural code from the analysis code - just to make it easier to read and to help you in debugging. It would also be helpful to comment the code so that someone could tell what it is you're trying to do at each step.
Finding the peak of the fft energy is probably an OK way to find the fundamental frequency. Once you have that, it should be easy to calculate the period as long as you know the frequency scale to begin with.
The frequency index I at which you find the peak represents:
fp=(I-1)*fs/N Hz
so, as a check, the maximum frequency that you can find is (N-1)*fs/N or fs-fs/N which is the expected result. Of course, since the data is sampled, the actual peak will be below fs/2 and will repeat above fs/2.
The period of the fundamental estimated this way is:
1/fp
So much for the period in #1.
I don't understand your objective #2. It makes no sense to me. Perhaps you can clarify. Why is it different than #1?
You didn't address #3. You might A) remove the mean so the result is zero mean. then B) compute a suitably short-term average of the signal using an odd number of elements and find where the zero-crossings are relative to the center of the averaging filter.
Fred
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

what
you
sampled,
you
of
I am appending comments about the codes used below. ********************************************* Yftc = fft(cc); % Calculates the fourier transform of the controlled signal Yft = fft(c); % Calculates the fourier transform of the chaotic signal
Nc = length(Yftc); % Calculates the number of samples in the controlled signal N = length(Yft); % Calculates the number of samples in the chaotic signal
Yftc(1) = []; % Removes the first element (mean value) of the FFT transformed signal Yft(1) = []; % Removes the first element (mean value) of the FFT transformed signal
powerc = abs(Yftc(1:Nc/2)).^2; % Calculates the power of the controlled signal power = abs(Yft(1:N/2)).^2; % Calculates the power of the controlled signal
nyquistc = 1/2; % Dont know why this stamement is used?? Copied from the documentation file nyquist = 1/2; % Dont know why this stamement is used?? Copied from the documentation file
freqc = (1:Nc/2)/(Nc/2)*nyquistc; % Calculates the frequencies of the controlled signal freq = (1:N/2)/(N/2)*nyquist; % Calculates the frequencies of the chaotic signal
periodc = 1./freqc; % Calculates the period of oscillations for the controlled signal period = 1./freq; % Calculates the period of oscillations for the chaotic signal
[mpc,indexc] = max(powerc); % Calculates the maximum power periodc(indexc) % Finds the time period of oscillations of the maximum frequency component
************************************************
As for the statement #2: I wanted to find the frequency component of the signal if its a period 2 oscillation, or higher. So I guess the power spectrum would show 2 peaks if its a period 2 oscillation. In that case, would the fundamental frequency still give me the appropriate time period.
For statement #3: I didn't understand your statement: "compute a suitably short-term average of the signal using an odd number of elements and find where the zero-crossings are relative to the center of the averaging filter". Could you please elaborate it further.
Thanks for your help and suggestions. *******************

I don't know what you mean by a "period 2 oscillation"
nyquist = 1/2 is the normalized case where we assume that fs=1 and fs/2=1/2 and fs/2 is always the nyquist frequency.
So, it appears if you were to use nyquist00 for fs 00 that would fit into the scheme of the code. Or, whatever numbers suit your implementation.
I don't think you *need* to remove the mean after the fft but you may want to remove the mean *before* the fft depending on what you intend to do next.
My comments about finding the location of the zero crossings apply to processing in the time domain.
Fred
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Period 2 oscillations are those type of oscillations which has 2 distinct loops in a phase phase, unlike a period 1 oscillation (more commonly known as the limit cycle) which has a single loop in the phase plane. Higher period oscillations would have similar higher number of loops in the phase plane.
Regards Ankur
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Ankur wrote:

In other words it's a chaotic systems thing. One of the 'routs to chaos' as a system's gain goes up is the bifurcation of the period, until finally things just go to hell.
--

Tim Wescott
Wescott Design Services