[英]Maximum amplitude of FFT data
我需要幫助找到FFT信號的最大幅度。
假設我對音頻文件執行FFT並獲得一列復數,如何從FFT信號中提取最大幅度及其索引? 我嘗試使用“最大”語法,但出現錯誤: 下標索引必須是實數正整數或邏輯值。
希望能有所幫助。.Thanx
這是我使用的代碼
[wave,fs]=wavread('c scale fast.wav'); % read file into memory */
%sound(wave,fs); % see what it sounds like */
t=0:1/fs:(length(wave)-1)/fs; % and get sampling frequency */
figure(90);
subplot(2,1,1)
%plot(t,wave)
plot(t,abs(wave))
title('Wave File')
ylabel('Amplitude')
xlabel('Length (in seconds)')
L = length(wave);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(wave,NFFT)/L;
f = fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
subplot(2,1,2)
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
A = max(Y)
fft返回一個復數。 您應該使用絕對值來找到最大值:
[maxY,indexOfMaxY] = max(abs(Y));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.