How to plot Fourier transform against frequency?
Mostrar comentarios más antiguos
I am trying to plot the fourrier transform against frequency rather than bins. How do I do this? I belive the mistake is in creating f_axis
n = 400 %number of points
F1 = 3 %frequency 2
F2 = 2 %frequency 1
NT = 1.33 %number of periods
T = 2*pi/(F1-F2) %one period
L = NT*T %length of signal
m = zeros(1,n/20)
p = zeros(1,n/20)
for N = 20:20:n
t = 0:L/N:L-L/N % time axis given by N points counting from 0 to NT periods
y = cos(t.*(F1+F2)).*cos(t.*(F1-F2)) %signal
%%% Windowing %%%
win = gausswin(N)
y = y'.*win
%%% Zero padding %%%
Nz = 1000 % number of zeros to pad with
y = [y' zeros(1,Nz)]
%%% Fourier Transform %%%
Y = fftshift(fft(y))
%%% Extract the maxima %%%
[pks,locs] = findpeaks(abs(Y))
m(N/20) = m(N/20)+locs(3)
p(N/20) = p(N/20)+locs(4)
end
%%% plot against frequecy rather than bins %%%
Ntotal = Nz + n
Df=1/((Ntotal)*L/n)
f_axis=(0:1:(Ntotal-1))*Df
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




















