Convert signal from time domain to frequency domain with fft

35 次查看(过去 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));

采纳的回答

Star Strider
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 个评论
Zaref Li
Zaref Li 2021-5-4
Thank you for your help. It was said that normalization to the signal should also be common. I was told that I need to divide by the fft size, L. Where do I write this / L statement?
Star Strider
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 CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by