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?

6 ビュー (過去 30 日間)
yfft=fft(y); % fft of original signal
N=length(y);
f=(-1/2:1/N:1/2-1/N)*fs;
plot(f,k);

採用された回答

Wayne King
Wayne King 2013 年 4 月 29 日
編集済み: Wayne King 2013 年 4 月 29 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by