Referring to the Gaussian Pulse in Time Domain (2nd example of https://uk.mathworks.com/help/matlab/ref/fft.html ) I want to highlight 2 things:
1) In this example you write:
Fs = 100; % Sampling frequency
t = -0.5:1/Fs:0.5; % Time vector
L = length(t); % Signal length
X = 1/(4*sqrt(2*pi*0.01))*(exp(-t.^2/(2*0.01)));n = 2^nextpow2(L);Y = fft(X,n);f = Fs*(0:(n/2))/n;P = abs(Y/n);plot(f,P(1:n/2+1))
but this is wrong. It should instead be:
Fs = 100; % Sampling frequencyt = -0.5:1/Fs:0.5; % Time vector L = length(t); % Signal lengthX = 1/(4*sqrt(2*pi*0.01))*(exp(-t.^2/(2*0.01)));n = 2^nextpow2(L);Y = fft(X,n)f = Fs*(0:(n/2))/n;P = abs(Y/L);plot(f,P(1:n/2+1))
2) I do not get why in this example, differently from the other two examples, you do not multiply by 2 the vector P. In other words, I would expect something like this:
P = abs(Y/L);P = P(1:n/2+1);P(2:end-1) = 2*P(2:end-1);
I made a comparison with the analytical solution and indeed it turns out that it is correct not to multiply by 2, but why is that?
Thanks
Best Answer