How to plot ifft for a frequency signal?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I've a .dat file (attaching the .mat file of that .dat file after converting, since this platform doesn't allow to upload .dat file while asking question) which represent the frequency spectrum of a vibration signal from a bearing having a sampling frequency of (fs=32768). How to convert the frequency signal to time domain signal. Please help.
3 commentaires
Scott MacKenzie
le 6 Août 2021
Modifié(e) : Scott MacKenzie
le 6 Août 2021
Have you tried? Please post the code you've attempted so far.
Réponse acceptée
Yazan
le 6 Août 2021
Modifié(e) : Yazan
le 6 Août 2021
clc, close all
fs = 32768;
fidx = z.Date23122013;
specOneSide = z.Time100351;
[fidx, idx] = unique(fidx);
specOneSide = specOneSide(idx);
fOneSide = (fidx./fidx(end))*fs/2;
subplot(1,2,1)
plot(fOneSide, specOneSide), xlabel('Frequency - Hz'), ylabel('Magnitude spectrum');
axis tight, title('One-sided spectrum');
specTwoSide = [flip(specOneSide(1:end)); specOneSide(2:end-1)];
N = length(specTwoSide);
f = -fs/2:fs/N:fs/2-fs/N;
subplot(1,2,2)
plot(f, specTwoSide), xlabel('Frequency - Hz'), ylabel('Magnitude spectrum');
axis tight, title('Two-sided spectrum');
sig = ifft(fftshift(specTwoSide));
figure,
t = (0:N-1)./fs;
plot(t, sig), axis tight, title('Signal');
xlabel('Time - sec'), ylabel('Amplitude');
5 commentaires
Yazan
le 6 Août 2021
Notice that the values of the Date23122013 (or your frequency axis points) are not unique. Also, for one value of Date23122013, you have sometimes multiple values of Time100351. My code uses the first appearing value of Time100351 for a given Date23122013 automatically, which is sometimes zero, but you might prefer otherwise. It is always a good idea to clean your data first.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!