coeffs
Get filter coefficients
Syntax
Description
Examples
Get graphicEQ
Coefficients
Create a graphicEQ
and then call coeffs
to get its coefficients. The coefficients are returned as second-order sections. The dimensions of B
are 3-by-(M
* EQOrder
/ 2), where M
is the number of bandpass equalizers. The dimensions of A
are 2-by-(M
* EQOrder
/ 2).
fs = 44.1e3; x = 0.1*randn(fs*5,1); equalizer = graphicEQ('SampleRate',fs, ... 'Gains',[-10,-10,10,10,-10,-10,10,10,-10,-10], ... 'EQOrder',2); [B,A] = coeffs(equalizer);
Compare the output of the filter
function using coefficients B
and A
with the output of graphicEQ
.
y = x; for section = 1:equalizer.EQOrder/2 for i = 1:numel(equalizer.Gains) y = filter(B(:,i*section),A(:,i*section),y); end end audioOut_filter = y; audioOut = equalizer(x); subplot(2,1,1) plot(abs(fft(audioOut))) title('graphicEQ') ylabel('Magnitude Response') subplot(2,1,2) plot(abs(fft(audioOut_filter))) title('Filter function') xlabel('Bin') ylabel('Magnitude Response')
Get gammatoneFilterBank
Coefficients
Create the default gammatoneFilterBank
, and then call coeffs
to get its coefficients. Each gammatone filter is an eighth-order IIR filter composed of a cascade of four second-order sections. The size of B
is 4-by-3-by-NumFilters
. The size of A
is 4-by-2-by-NumFilters
.
[audioIn,fs] = audioread('Counting-16-44p1-mono-15secs.wav'); gammaFiltBank = gammatoneFilterBank('SampleRate',fs); [B,A] = coeffs(gammaFiltBank);
Compare the output of the filter
function using coefficients B
and A
with the output of gammaFiltBank
. For simplicity, compare output from channel eight only.
channelToCompare = 8; y1 = filter(B(1,:,channelToCompare),[1,A(1,:,channelToCompare)],audioIn); y2 = filter(B(2,:,channelToCompare),[1,A(2,:,channelToCompare)],y1); y3 = filter(B(3,:,channelToCompare),[1,A(3,:,channelToCompare)],y2); audioOut_filter = filter(B(4,:,channelToCompare),[1,A(4,:,channelToCompare)],y3); audioOut = gammaFiltBank(audioIn); t = (0:(size(audioOut,1)-1))'/fs; subplot(2,1,1) plot(t,audioOut(:,channelToCompare)) title('Gammatone Filter Bank') ylabel('Amplitude') subplot(2,1,2) plot(t,audioOut_filter) title('Filter Function') xlabel('Time (s)') ylabel('Amplitude')
Get octaveFilterBank
Coefficients
Create the default octaveFilterBank
, and then call coeffs
to get its coefficients. The coefficients are returned as second-order sections. The dimensions of B and A are T-by-3-by-M, where T is the number of sections and M is the number of filters.
[audioIn,fs] = audioread('Counting-16-44p1-mono-15secs.wav'); octFiltBank = octaveFilterBank('SampleRate',fs); [B,A] = coeffs(octFiltBank);
Compare the output of the filter
function using coefficients B
and A
with the output of octaveFilterBank
. For simplicity, compare output from channel five only.
channelToCompare = 5; audioOut_filter = filter(B(1,:,channelToCompare),A(1,:,channelToCompare),audioIn); audioOut = octFiltBank(audioIn); subplot(2,1,1) plot(audioOut(:,channelToCompare)) title('Octave Filter Bank') subplot(2,1,2) plot(audioOut_filter) title('Filter Function')
Input Arguments
obj
— Object to get filter coefficients from
gammatoneFilterBank
| octaveFilterBank
| graphicEQ
Object to get filter coefficients from, specified as an object of gammatoneFilterBank
, octaveFilterBank
, graphicEQ
, or
shelvingFilter
.
Output Arguments
B
— Numerator filter coefficients
matrix | 3-D array
Numerator filter coefficients, returned as a 2-D matrix or 3-D array, depending on
obj
.
Data Types: single
| double
A
— Denominator filter coefficients
matrix | 3-D array
Numerator filter coefficients, returned as a 2-D matrix or 3-D array, depending on
obj
.
Data Types: single
| double
Version History
Introduced in R2019aR2020b: SOS returned instead of FOS from octaveFilterBank
The coeffs
function of octaveFilterBank
now returns the filter in second-order sections (SOS) instead of fourth-order sections
(FOS). This new format reflects an updated internal representation, which has been enhanced
to remain stable at very low frequencies.
See Also
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)