Convert signal from time domain to frequency domain with fft
58 次查看(过去 30 天)
显示 更早的评论
Hello to everyone
I have signal and time arrays. for example;
signal1 = 1x609
signal1 = [0.0068, 0.0166, ..., 0.5054]
T = 1x609
T = [48.4044, 48.6210, ..., 179.1312]
I wrote a code like this to convert this signal to frequency medium, but I don't know how to determine its frequency. I would be very happy if you could help me with this subject.
X=fftshift(fft(signal1));
fs=10;
df=fs/N; % the frequency increment
f=-fs/2:df:fs/2-df;
figure;
plot(f,abs(X));
0 个评论
采纳的回答
Star Strider
2021-5-4
If ‘T’ (that I assume is the time vector) is regularly-sampled (constant sampling intervals), first determine the sampling intervals, then use them to calculate the frequency vector:
L = numel(T); % Length Of Time & Signal Vectors
Ts = mean(diff(T)); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Fv2 = linspace((-Fn, Fn, L); % Frequency Vector For Two-Sided Fourier Transform
The fftshift call leads me to believe that the goal is to plot the two-sided Fourier transform.
If the signal is not regularly-sampled, it must be converted to regular sampling to do any reliable signal processing on it. Use the resample function for that purpose first, then calculate the fft and any other signal processing on the resampled signal.
4 个评论
Star Strider
2021-5-4
As always, my pleasure!
Normalise it in the fft call —
X = fftshift(fft(signal1)/L);
Note — The ‘L’ calculation and assignment needs to go before the ‘X’ calculation and assignment.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!