Understanding this FFT Graph
Show older comments
I have plotted a graph using FFT function; using a sweep sine wave.
The code is generic NFFT = 2^nextpow2(L) and using absolute values to plot FFT values on the Y axis.
My question is; what would the label be for the Y-axis and secondly, is the X axis just frequency in the time domain?
Any help greatly appreciated.
T=5; %size of window
fs=44100; %sampling frequency
df=1/T; %frequency res
dt=1/fs; %time resolution
t=(0:+dt:T-dt); %time vector
df_t=500; %swept rate (Hz/seconds)
% pre-allocate size of t:
sweptsin = zeros(size(t));
for i=1:+1:length(t)
%i=i+1;
if(i==1) %initialise f and t.
f=20; ti=0;
else
ti=ti+dt; %time increment
f=f+df_t*dt; %freq increment
end
w=2*pi*f; %omega
sweptsin(i)=sin(w*ti); %swept sine wave
end
sound(sweptsin, fs)
figure
y = cos(2*pi*f*t)+randn(size(t));
L = 1000;
NFFT = 2^nextpow2(L);
Y = abs(fft(y,NFFT))/L;
f = fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2+1)))
xlim([0 22050])
ylim([0 0.8])
Accepted Answer
More Answers (1)
Categories
Find more on Discrete Fourier and Cosine Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!