フィルターのクリア

Plot single-sided amplitude spectrum.

46 ビュー (過去 30 日間)
mohamad mohamad
mohamad mohamad 2014 年 12 月 15 日
コメント済み: Stephen Capasso 2021 年 8 月 17 日
hello .
i tried to find a code for ploting fft,and i found this code which plot single-sided amplitude spectrum according to it's title,is it the same as fft?what is different between single side amplitude spectrum and fft? and is this code ok?
i really appreciate it if you help me.
i have a signal with 135 data point.
Fs = 50; % Sampling frequency T = 1/Fs; % Sample time L = 135; % Length of signal
NFFT = 2^(nextpow2(L)-1);
x=zeros(NFFT,1); x(1:NFFT,1) = rawdata(1:NFFT,1);
YY = fft(x,NFFT)/L; ff = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum. plot(ff,2*abs(YY(1:NFFT/2+1))) title('Single-Sided Amplitude Spectrum of tp') xlabel('Frequency (Hz)') ylabel('|Y(f)|')
  2 件のコメント
sampath kumar kuppa
sampath kumar kuppa 2016 年 11 月 4 日
you got the solution for this code or not. I'm also facing the same problem. if you got the solution means please forward to me.
Stephen Capasso
Stephen Capasso 2021 年 8 月 17 日
This has been useful does anyone know how to adjust the plot statement for log space instead of linspace. ff= Fs/2*logspace(0,1,NFFT/2+1); What would go in the argument for a 4 cycle semi log?

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

採用された回答

Adam
Adam 2014 年 12 月 15 日
編集済み: Adam 2014 年 12 月 15 日
That code uses the fft so yes, it is the same thing.
The fft is a transform which gives you a complex result spanning negative and positive frequencies ( -nyquist to +nyquist ). The single-side spectrum throws away the negative frequencies which are often not required for things like plotting spectrum to obtain a single-side spectrum.
So the fft is the method used to transform from the time domain to the frequency domain, but its result requires some manipulation afterwards to obtain what is often the desired result, a single-sided power spectrum.
The code:
ff = Fs/2*linspace(0,1,NFFT/2+1);
is taking the positive half of the spectrum (NFFT/2 +1 gives this, including 0 and nyquist, hence the +1) and mapping it onto your real frequencies from 'normalised frequency'.
  8 件のコメント
Xu LinaM
Xu LinaM 2017 年 3 月 1 日
Hello,after I read your opinion about Single-Sided Amplitude Spectrum,I have a question that where is the negative frequency,why they begin at NFFT/2+2,and what's the order of the size ?Thank you for your reply.Best Wishes!
Adam
Adam 2017 年 3 月 1 日
The negative frequencies begin at NFFT/2 + 2 simply because that is how fft is defined. They have to be somewhere. You can use fftshift if you prefer to have 0 in the centre with negative frequencies before it.

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

その他の回答 (1 件)

Charanraj
Charanraj 2015 年 7 月 9 日
hey, can a single sided FFT taken directly from the scope by using an absolute block before the scope ?

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by