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
채택된 답변
추가 답변 (1개)
Dr. Seis
2011년 12월 7일
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));
카테고리
도움말 센터 및 File Exchange에서 Spectral Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!