⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 find_f.m

📁 基于matlab的面向对象的信号处理类库。主要应用于音频、语音信号的一些处理。内含简单的使用说明
💻 M
字号:
function [f]=find_f(x,varargin)% FIND_F  Find fundamental frequency and harmonics%%    F=FIND_F(X)%%    Find fundamental frequency and harmonics.% $Id: find_f.m 106 2006-02-13 12:32:11Z mairas $f0 = -1;if nargin > 2    if strcmp(varargin{1},'F0')        f0 = varargin{2};    endendlx = len(x);fftsize = 2^(floor(log(lx)/log(2))+1);% get frequency response X=fft(x,fftsize);Xabs=abs(X);% get f0if f0 == -1    f0 = find_f0(x);end% check F0if f0 == 0    % no F0 found - return with null    f = [];    returnend% get N (vector of harmonics to get)N = 1:floor((x.time.fs/2)/f0);% find local peaksf_N=N;  % initialise to the final sizefor i=N  f_N(i) = localmax(Xabs,f0,i);endf=[f_N x.time.fs-fliplr(f_N)];%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function f=localmax(Xabs,f0,N)% LOCALMAX Find a largest spectral peak around N*f0%   F=LOCALMAX(XABS,FX,F0,N) returns the frequency, at which XABS%   gains its largest value. XABS is the absolute magnitude%   spectrum, FX are the corresponding frequency points, F0 is the%   assumed fundamental frequency and N is the order of harmonics.fmin=(N-0.5)*f0;fmax=(N+0.5)*f0;Imin=at(Xabs,fmin);Imax=at(Xabs,fmax);[foo,I]=max(Xabs(Imin:Imax));f = Xabs.frequency.f(Imin-1+I);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -