Hi, i have a time domine plot (displacement vs time). i want to convert to frequency domine plot (amplitude vs frequency).

5 ビュー (過去 30 日間)
SAJEEV R K
SAJEEV R K 2015 年 10 月 29 日
回答済み: Julian Sowa 2021 年 6 月 27 日
Hi, i have a time domine plot (displacement vs time). i want to convert to frequency domine plot (amplitude vs frequency).

回答 (1 件)

Julian Sowa
Julian Sowa 2021 年 6 月 27 日
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)|')

Community Treasure Hunt

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

Start Hunting!

Translated by