time_shift_fft | R Documentation |
Takes already calculated values of an fft and applies the relation between a shift in time domain and a multiplication by a complex factor in the frequency domain to obtain a shifted time signal.
time_shift_fft(fft_vals, sampling, time_shift)
fft_vals |
Values of the fourier transform of a function calculated at the frequencies given by sampling$fft_freqs. |
sampling |
An object providing information on the sampling paramters chosen. Usually constructed by the function create.sampling. |
time_shift |
The desired time shift in SI units, i.e. seconds. |
FFT values of the same frequencies as in fft_vals, but s.t. they produce a time-shifted signal when inverse transformed.
This function will work but most likely produce undesired results when applied to signals of even length that have a non-zero coefficient at Fs/2. This coefficient is required to have a purely real coefficient for the inverse transformed signal to be purely real. However, the time-shift operation will possibly multiply this coefficient by a complex factor, thus resulting in a complex (as opposed to purely real) inverse FFT.
t <- seq(0.1, 1, 0.1) y <- sin(2*pi*t) fft_shifted <- semg.simulatr:::time_shift_fft( fft_vals = fft(y) / length(y), sampling = semg.simulatr:::create_sampling(Fs = 10, NFFT = 10), time_shift = 0.2) dev.new() plot(t,y) points(t,Re(fft(fft_shifted, inverse = TRUE)), col = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.