Hi, i have a time domine plot (displacement vs time). i want to convert to frequency domine plot (amplitude vs frequency).
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, i have a time domine plot (displacement vs time). i want to convert to frequency domine plot (amplitude vs frequency).
0 commentaires
Réponses (1)
Julian Sowa
le 27 Juin 2021
Hello I have done this a bunch of time with the FFT function. I follow this tutorial and just use the example code they give: https://www.mathworks.com/help/matlab/ref/fft.html
Here is the example: Just replace the first 5 lines with your paramaters! LMK if it works for you.
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
X = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t); % Replace this with the array of your displacement samples
plot(1000*t(1:50),X(1:50))
title('Time Domain')
xlabel('t (milliseconds)')
ylabel('X(t)')
Y = fft(X);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
figure
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t) (Frequency Domain)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
0 commentaires
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!