Non-Constant Frequency & FFT

Hi all, I am trying to complete a FFT analysis for Temperature vs. time data recorded via a thermocouple. Instead of a constant recording frequency of 100Hz, the signal alternates betwen 100Hz (one sample per 10ms) and 90Hz (one sample per 11ms). Because of this, is it possible to complete an FFT? Temp and time data are the same length.
Here is the code I am writing....
time=xlsread(spreadsheet, sheetname, range_1); %% Load temp data T_t=xlsread(spreadsheet, sheetname, range_2); %% Load Temp data
Xf=fft(T_t); %% FFT of Temp mag=abs(Xf); %% absolute value of FFT phase=angle(Xf)*360/(2*pi); fs=100; %% Unsure what to use here N=length(time); %% Length of data f=(1:N)*fs/N; %% Frequency, again, unsure what to use here for semilogy(f, mag);
Any comments/thoughts are very helpful!
Thanks!
-Scott

 Accepted Answer

Greg Heath
Greg Heath on 8 Dec 2011

0 votes

See my answer to your newsgroup posting.
Hope this helps.
Greg
P.S. I don't think MATLAB wants you to post the same question to the Newsgroup and Answers.

More Answers (1)

You can always interpolate the data to regular spaced 90Hz data. This can be done upfront with the time domain data or you can keep the irregular time data and code up a version of DFT that can give you regular spaced data in the frequency domain.
If your time data is store in "timedata" and corresponding time information stored in "time", then this would look something like this (example using random spacing in time):
time = sort(rand(1,512))*4;
timedata = sin(2*pi*time);
figure;
plot(time,timedata);
N = numel(time);
dt = 1/90; % You are prescribing the time increment
df = 1/(N*dt);
Nyq = 1/(dt*2);
freq = -Nyq:df:Nyq-df;
freqdata = zeros(size(timedata));
for i = 1 : N
for j = 1 : N
freqdata(i) = freqdata(i) + timedata(j)*exp(-1i*2*pi*freq(i)*time(j));
end
end
figure;
plot(freq,real(freqdata),freq,imag(freqdata));

Tags

Community Treasure Hunt

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

Start Hunting!