how to acces the points on the fft plot.

조회 수: 3 (최근 30일)
777
777 2012년 3월 9일
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.

채택된 답변

Wayne King
Wayne King 2012년 3월 9일
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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by