i want frequency domain spectrum of an audio file and i want to set frequency range of about 3 kHz. it is showing range upto 10 kHz. how can i modify it?

7 Ansichten (letzte 30 Tage)
yfft=fft(y); % fft of original signal
N=length(y);
f=(-1/2:1/N:1/2-1/N)*fs;
plot(f,k);

Akzeptierte Antwort

Wayne King
Wayne King am 29 Apr. 2013
Bearbeitet: Wayne King am 29 Apr. 2013
You have a couple things here. For one, you are creating a frequency vector with 0 frequency at the center. Do you really need the "negative" and "positive" frequency content? If so, then do the following:
fs = 1e4;
t = 0:1/fs:1-1/fs;
y = cos(2*pi*1000*t)+1/2*sin(2*pi*2000*t)+randn(size(t));
DF = fs/length(y);
ydft = fftshift(fft(y));
N = length(y);
f=(-1/2:1/N:1/2-1/N)*fs;
plot(f,abs(ydft))
set(gca,'xlim',[-3000 3000]);
If that is not necessary:
fs = 1e4;
t = 0:1/fs:1-1/fs;
y = cos(2*pi*1000*t)+1/2*sin(2*pi*2000*t)+randn(size(t));
ydft = fft(y);
% assuming length(y) is even
f = 0:fs/length(y):fs/2;
plot(f,abs(ydft(1:length(y)/2+1)))
You can easily just extract the Fourier transform coefficients that correspond to [-3000 3000] or [0 3000] if that is what you want. Since the frequency interval between elements in ydft is just fs/length(y), just pull out the elements corresponding to the frequencies you want.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by