matlab中的 melbankm函数
时间: 2024-01-28 13:03:07 浏览: 194
melbankm函数是MATLAB中的一个信号处理工具箱函数,用于计算Mel滤波器组系数矩阵。Mel滤波器是一种常用的信号处理工具,常用于语音信号的频率分析和特征提取。
该函数的语法格式为:
[H, F, M] = melbankm(M, N, fs, fmin, fmax, h)
其中,M为Mel滤波器组数;N为FFT点数;fs为采样率;fmin为最低频率;fmax为最高频率;h为Mel滤波器带宽。
函数返回三个参数:
- H:Mel滤波器组系数矩阵,大小为M x (N/2+1);
- F:Mel滤波器组中心频率;
- M:Mel滤波器组边界频率。
该函数的作用是计算Mel滤波器组系数矩阵,用于将输入信号转换到Mel频率域。Mel频率域是一种将频率划分为更符合人耳感知的频带的方式,因此常用于语音信号的特征提取。
相关问题
melbankm函数的代码
以下是melbankm函数的代码,它用于计算梅尔倒谱系数:
```matlab
function [m, f, c] = melbankm(p, n, fs, fmin, fmax, s)
% MELBANKM Determine matrix for a mel-spaced filterbank
%
% [M,F,C]=MELBANKM(P,N,FS,FMIN,FMAX,S) returns matrix M (size P x N) for
% a mel-spaced filterbank which is to be applied to the rows of a N-point
% signal X. The filter bank ranges from FMIN to FMAX (in Hz) and
% contains P filters (default 20). Each filter has a triangular
% spectral shape, as prescribed by the MEL scale, and is uniformly
% spaced on that scale. The triangular shape extends three bins
% (one on each side) into the neighbouring filters. S is the scale
% factor for the FFT (default 2). Thus, if the FFT is of length N,
% the triangular filters are N/S points wide. FS is the sample rate
% (default 16000).
%
% The output matrix F (size P x 1) contains the center frequencies
% of each band in the filterbank. The final output C (size N x P)
% can be used to plot the response of the filterbank to a signal
% using PLOT(F,20*log10(abs(C))), for example.
%
% See also HZ2MEL, FFT2BANK, AUD2DB, FILTERBANK.
% References:
% [1] Huang, X., Acero, A., Hon, H., 2001. Spoken Language Processing:
% A guide to theory, algorithm, and system development. Prentice Hall.
% [2] Fant, G., 1960. Acoustic Theory of Speech Production. Mouton.
% [3] T. Barnwell, "Speech analysis/synthesis based on a sinusoidal
% representation," IEEE Trans. Acoust., Speech, Signal Process.,
% vol. 34, pp. 744-754, Aug. 1986.
% Author: Kamil Wojcicki, UTD, June 2011
if nargin<6; s = 2; end
if nargin<5; fmax = fs/2; end
if nargin<4; fmin = 0; end
if nargin<3; fs = 16000; end
if nargin<2; n = 256; end
if nargin<1; p = 20; end
fmin = max(fmin,0);
if (2*s*floor(n/2))~=n; n=n+1; end % Make sure that N is even
fmax = min(fmax,fs/2);
n2 = floor(n/2);
% Compute Mel scale and corresponding frequencies
melmax = hz2mel(fmax);
melmin = hz2mel(fmin);
melp = linspace(melmin,melmax,p+2);
f = mel2hz(melp);
r = round(f/fs*n);
% Design matrix using triangular filters
c = zeros(n,p);
for k = 2:p+1
f1 = r(k-1);
f2 = r(k);
f3 = r(k+1);
c(f1:f2,k-1) = (0:(f2-f1))/(f2-f1);
c(f2:f3,k-1) = (f3-(0:(f3-f2)))/(f3-f2);
end
% Done!
m = dctmtx(p)';
m(1,:) = m(1,:) * sqrt(1/2);
m = m*c;
end
function f = mel2hz(m)
% MEL2HZ Convert frequency from mel scale
%
% F = MEL2HZ(M) converts frequencies M from the mel scale to the
% Hz scale. Input and output are in units of Hz.
% Author: Kamil Wojcicki, UTD, June 2011
f = 700*(10.^(m/2595)-1);
end
function m = hz2mel(f)
% HZ2MEL Convert frequency from Hz scale to mel scale
%
% M = HZ2MEL(F) converts frequencies F from the Hz scale to the
% mel scale. Input and output are in units of Hz and mel,
% respectively.
% Author: Kamil Wojcicki, UTD, June 2011
m = 2595*log10(1+f/700);
end
```
此函数的功能是生成一个用于计算梅尔倒谱系数的滤波器组。
matlab melbankm
matlab中的melbankm函数是用于计算mel滤波器组的函数。mel滤波器组是一组滤波器,通常应用于语音信号处理任务中,用于将频率轴上的线性频率划分为一系列的三角形,以便更好地模拟人耳对声音的感知。
melbankm函数的语法如下:
```
[h, f, c] = melbankm(p, n, fs, f0, f1)
```
其中,p是滤波器的数量,n是FFT的长度,fs是采样频率,f0是最低频率,f1是最高频率。函数返回值h是一个p×(n/2+1)的矩阵,表示p个mel滤波器的频率响应;f是一个长度为n/2+1的向量,表示FFT的频率轴;c是一个p×2的矩阵,表示每个mel滤波器的中心频率和带宽。
使用melbankm函数可以方便地计算mel滤波器组,并将其应用于语音信号处理任务中的特征提取。
阅读全文