FFT example Syntax what does it means P1(2:end-1) = 2*P1(2:end-1); ?
54 ビュー (過去 30 日間)
In the Matlab example for the FFT they describe how to plot the FFT.
"Compute the Fourier transform of the signal.
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);
Why P1(2:end-1)= 2*P1(2:end-1)? What does it means (2:end-1)? I tried to deduce creating other example with some matrix, but i don't understand Why (1:L/2+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. _
f = Fs*(0:(L/2))/L;
title('Single-Sided Amplitude Spectrum of X(t)')
This is my first time I approach to the FFT, and I have a civil engineer background, so is my first time with signal analysis, never studied Signal Theory before.
My interest for the FFT is to define the best low pass filter (example apply a butterworth but I don’t know how to choose the filter order and cutoff frequency.
Thanks in advance :)
回答 (3 件)
Jonas 2021 年 5 月 18 日
編集済み: Jonas 2021 年 5 月 18 日
means that all values of the spectrum get doubled because of the conversion from two sided spectrum (which is symmetrical and has half signal frequency amplitude at positive and negative frequency) to one sided spectrum, which adds the spectrum amplitude of negative frequencies to the amplitude of the positive frequencies. the first value is not doubled, because it is the DC value (the mean of the signal, frequency 0Hz) which occurs only once in the spectrum and has already the true amplitude. the last spectrum frequency (index end) is also not doubled because it occurs also only once in the spectrum
e.g. the spectrum's x axis for the fft output is [0 1 2 -3 -2 1] Hz and we want a full one sided spectrum and we catch the amplitudes with index 1 to 4 (which is (1:L/2+1) by the way) which are the amplitudes of frequencies 0 1 2 -3. first and last frequency occur only once so we dont double them. want the tutorial does not say is that the default output of fft does not have the 0 frequency in the center like we want to see that for a two sided spectrum, the desired view is achieved with a fftshift(), which circularily shifts the frequency by half the entries, which results into the order of [-3 -2 -1 0 1 2], but since you would then have to find the index of frequency zero and double the right half of the values and matlab wants to avoid unnecessary steps and does not want to shift and truncate the left half afterwards. so the tutorial is fast but too fast to understand that correctly
the decision which filter you should choose depends fully on your signal and what frequencies are interesting at the end
Waldemiro Kubucama 2021 年 12 月 14 日
Means that it initializes from column 2 to the second-to-last column (end-1)