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 (최근 30일)
이전 댓글 표시
yfft=fft(y); % fft of original signal
N=length(y);
f=(-1/2:1/N:1/2-1/N)*fs;
plot(f,k);
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!