How can I plot 'period' by using fft functoin??

7 ビュー (過去 30 日間)
Chris
Chris 2021 年 11 月 7 日
コメント済み: Mathieu NOE 2021 年 11 月 8 日
How can I plot 'period' by using fft functoin??
  1 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 11 月 8 日
hello
maybe you should show what you have tried so far... and then we will help you
tx

サインインしてコメントする。

採用された回答

Chunru
Chunru 2021 年 11 月 8 日
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
X = S + 2*randn(size(t));
Y = fft(X);
% Compute the two-sided spectrum P2. Then compute the single-sided spectrum P1
% based on P2 and the even-valued signal length L.
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
% Define the frequency domain f and plot the single-sided amplitude spectrum P1.
% The amplitudes are not exactly at 0.7 and 1, as expected, because of the added
% noise. On average, longer signals produce better frequency approximations.
figure
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
%% Plot the spectrum vs period (this can be done but rarely used)
figure
f = Fs*(0:(L/2))/L;
plot(1./f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('T - period (sec)')
ylabel('|P1(T)|')
xlim([0 0.2])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by