Convert signal from time domain to frequency domain with fft

86 vues (au cours des 30 derniers jours)
Zaref Li
Zaref Li le 3 Mai 2021
Commenté : Star Strider le 4 Mai 2021
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));

Réponse acceptée

Star Strider
Star Strider le 4 Mai 2021
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 commentaires
Zaref Li
Zaref Li le 4 Mai 2021
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 le 4 Mai 2021
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by