how to acces the points on the fft plot.

3 views (last 30 days)
i have the following code.i want the access of value of z1 at fs1=1000.
[z, f] = wavread('z.wav');
>> n=length(z)
n =
137728
>> fs1=(0:n-1)*(f/n);
>> z1=abs(fft(z));
plot(fs1,z1);
i have the values of z1 and fs1 separately.but i dont know how to find the value of z1 at specific fs1.plss help me with this.
would be really thankful.

Accepted Answer

Wayne King
Wayne King on 9 Mar 2012
Hi, If the signal is real-valued, it is better to not use the whole result of fft() since you are looking at the absolute value.
The spacing of the DFT bins is Fs/length(input) as you note in your code above.
t = 0:0.001:1-0.001;
Fs = 1000;
x = cos(2*pi*100*t)+randn(size(t));
xdft = fft(x);
xmag = abs(xdft(1:length(xdft)/2+1));
freq = 0:Fs/length(x):Fs/2;
Now, how do we find the value of xmag that corresponds to 100 Hz?
The spacing between the DFT bins is Fs/length(x), so
df = Fs/length(x);
freqbin = round(100/df)+1;
xmag(freqbin)
Of course if you want the actual Fourier coefficient at that frequency
xdft(freqbin)

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!