MATLAB Fouriertransform with nunequidistant values

조회 수: 10 (최근 30일)
Nils
Nils 2018년 7월 1일
편집: Vilnis Liepins 2018년 7월 2일
Hello there,
I am currently working on a frequencyanalysis. For this, I have a signal with a non-static signaling frequency. In other words, I have one vector 'y' with measurement (pixel with maximum intensity) and one vector 'time' with times inbetween measurements. Each value in the measurements vector corresponds to one measurements.
The sampling frequency is about 5 Hz, which is why I wrote this fft()-code:
load('y');
load('times')
Fs = 5;
Ts = 1/Fs;
nfft = length(y);
dt = 0:Ts:Ts*nfft-Ts;
ff = fft(y);
ff(1) = [];
nfft = length(ff);
ffabs = abs(ff(1:floor(nfft/2)+1));
freq = (1:length(ffabs))*Fs/length(y);
subplot(2,1,1);
plot(dt,y);
subplot(2,1,2)
plot(freq,ffabs);
This does the basic fouriertransform but does not incorperate the actual times for each measurement. The Vector times is built up of the times in secondy after the beginning of the measurement ([0.886769 1.125059 1.301065 1.497016 1.69091 1.885543 2.061231 ...]).
Does anyone have an idea how to incorperate these times into the code. Help is verymuch appreciated!!
Cheers

답변 (3개)

dpb
dpb 2018년 7월 1일
The simplest route is to interpolate to a fixed sample rate and apply the FFT to that series.
Alternatively there's a submission at FEX of the NUFFT FEX 25135

Star Strider
Star Strider 2018년 7월 1일
I would use the Signal Processing Toolbox resample (link) function to interpolate it to a regularly-sampled time base. There is an option to use a time vector created by the linspace function. Then use fft to take the Fourier transform. (If I remember correctly, there are File Exchange contributions that can deal with non-uniformly sampled data. Using reshape is likely easier.) The resample function uses an anti-aliasing filter to avoid the resampling problems encountered using interp1 alone, so use resample if you are going to be doing further signal processing on your data.

Vilnis Liepins
Vilnis Liepins 2018년 7월 2일
편집: Vilnis Liepins 2018년 7월 2일
You can apply File Exchange program 'nedft' available on https://se.mathworks.com/matlabcentral/fileexchange/11020-extended-dft.
load('y');
load('times')
Fs = 5;
Ts = 1/Fs;
nfft = length(y);
fr=[-ceil((nfft-1)/2):floor((nfft-1)/2)]/(nfft*Ts); % Uniform set of frequencies in [-1/2Ts,1/2Ts[
ff=fftshift(nedft(y,times,fr)); Calculate DFT on fr and fftshift

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by