【问题标题】:Maximum amplitude of FFT dataFFT数据的最大幅度
【发布时间】:2013-09-14 16:08:24
【问题描述】:

我需要帮助来找到 FFT 信号的最大幅度。

假设我对音频文件执行 FFT 并得到一列复数,我如何从 FFT 信号中提取最大幅度及其索引? 我尝试使用“max”语法,但出现错误:???下标索引必须是实数正整数或逻辑数。

不胜感激。谢谢

这是我用过的代码

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

【问题讨论】:

  • 你得到什么错误信息?
  • 这是错误 = "??? 下标索引必须是实数正整数或逻辑数。"
  • 你能画出 wav 数据吗?
  • 是的,时域和频域图都很完美。我在编写代码以在 FFT 图中找到最大幅度时遇到问题。
  • 好吧,但话又说回来,我的 FFT 不是整数,因此错误....

标签: matlab


【解决方案1】:

fft 返回一个复数。您应该使用绝对值来找到最大值:

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

【讨论】:

    猜你喜欢
    • 2020-08-25
    • 1970-01-01
    • 2019-09-05
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    • 2013-02-15
    • 1970-01-01
    • 2015-07-04
    相关资源
    最近更新 更多