Hi, i have a time domine plot (displacement vs time). i want to convert to frequency domine plot (amplitude vs frequency).
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, i have a time domine plot (displacement vs time). i want to convert to frequency domine plot (amplitude vs frequency).
0 Kommentare
Antworten (1)
Julian Sowa
am 27 Jun. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Spectral Measurements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!