what is the x-axis in the figure represent ? frequency, samples?

2 views (last 30 days)
Hi all....
I so confusing really!
I Have this code
Fs = 20000;
t = 0:1/Fs:0.01;
fc1=200;
x = 10*sin(pi*fc1*t)
xFFT = abs(fft(x));
x_psd = abs(fft(x).^2);
stem(xFFT);
stem(x_psd);
1.let we say this simple HW, what is the x-axis of xFFT represent(frequency or samples SPS)? 2.can I say this signal of frequency 100 ,sampling frequency 20000,number of samples 201? 3.How can find resolution of this can I say (Fs/number of samples N) is resolution, if not resolution how can find resolution ?
than you

Accepted Answer

Mohammad Abouali
Mohammad Abouali on 26 Nov 2014
the way that you are using stem function, the x axis would be the index number.
So your xFFT is an array of 201 double precision numbers. the x axis is from 1 to 201.
So pretty much you can interpret it as sample number.
use this form:
stem(xValues, YValues)
if you want to show something else as your x-axis.
Two more thing (not in your question)
1) usually use fftshift before plotting your stuff.
2) You have two calls to stem() function. The second one will override the first one. So either use 'hold on' to have both graph in one figure or if you want them in two separate figure then change it to something like this:
figure, stem(xFFT);
figure, stem(x_psd);

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!