Complete the code to compute the FFT of the signal x.
Y = fft([1]);The fft function computes the Fast Fourier Transform of the input signal x.
Complete the code to calculate the magnitude spectrum from the FFT result Y.
magnitude = abs([1]);The magnitude spectrum is the absolute value of the FFT result Y.
Fix the error in the code to compute the frequency vector for sampling frequency Fs and signal length N.
f = (0:[1]-1)*(Fs/[1]);
Fs instead of the signal length N in the vector range.The frequency vector f should be based on the length N of the signal.
Fill both blanks to compute the two-sided amplitude spectrum P2 and then the single-sided spectrum P1.
P2 = abs([1]/[2]); P1 = P2(1:floor([2]/2)+1);
P2 is the normalized magnitude of the FFT result Y divided by the signal length N. Then P1 takes the first half plus one element for the single-sided spectrum.
Fill all three blanks to plot the single-sided amplitude spectrum P1 against frequency vector f.
plot([1], [2]) xlabel('[3]')
f and P1 in the plot.The plot shows amplitude P1 versus frequency f. The x-axis label should be 'Frequency (Hz)'.
