简体   繁体   中英

Maximum amplitude of FFT data

I need help in finding the maximum amplitude of an FFT signal.

Say I perform FFT on an audio file and get a column of complex numbers, how can i extract the maximum amplitude and its index from the FFT signal?? I tried using the "max" syntax but i get an error: ??? Subscript indices must either be real positive integers or logicals.

Would appreciate some help.. Thanx

This is the code I've used

[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)

The fft returns a complex number. You should use the absolute Value to find the maximum:

[maxY,indexOfMaxY] = max(abs(Y));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM