ctf
Convert digital filter to coefficients in cascaded transfer function format
Since R2026a
Description
[
returns the numerator and denominator coefficients in the Cascaded Transfer Functions (CTF) format for the B,A] = ctf(filtObj)digitalFilter object or filter System object™.
Using a filter System object requires a DSP System Toolbox™ license.
Examples
Design a lowpass IIR filter with the passband frequency of 0.65π rad/sample and the stopband frequency of 0.80π rad/sample. The passband ripple is 1 dB and the stopband attenuation is 50 dB. Use the designfilt function to create a digitalFilter object with these specifications.
digiFilt = designfilt("lowpassiir", ... PassbandFrequency=0.65,StopbandFrequency=0.80, ... PassbandRipple=1,StopbandAttenuation=50)
digiFilt =
digitalFilter with properties:
Coefficients:
Numerator: [6×3 double]
Denominator: [6×3 double]
Specifications:
FrequencyResponse: 'lowpass'
ImpulseResponse: 'iir'
NormalizedFrequency: 1
StopbandAttenuation: 50
PassbandRipple: 1
StopbandFrequency: 0.8000
PassbandFrequency: 0.6500
DesignMethod: 'butter'
Use filterAnalyzer to visualize filter
Use designfilt to edit filter
Use filter to filter data
Get coefficients in the CTF format for this filter.
[num,den] = ctf(digiFilt)
num = 6×3
0.6865 1.3729 0.6865
0.5694 1.1388 0.5694
0.4953 0.9907 0.4953
0.4498 0.8996 0.4498
0.4250 0.8500 0.4250
0.6459 0.6459 0
den = 6×3
1.0000 0.9601 0.7857
1.0000 0.7964 0.4812
1.0000 0.6928 0.2885
1.0000 0.6291 0.1701
1.0000 0.5944 0.1056
1.0000 0.2917 0
Design a lowpass IIR filter of order 8 using the designLowpassIIR function. Set the SystemObject flag to true to generate a dsp.SOSFilter object. Set HasScaleValues to true.
sosFilt = designLowpassIIR(FilterOrder=8,HasScaleValues=true,...
SystemObject=true)sosFilt =
dsp.SOSFilter with properties:
Structure: 'Direct form II transposed'
CoefficientSource: 'Property'
Numerator: [4×3 double]
Denominator: [4×3 double]
HasScaleValues: true
ScaleValues: [0.1287 0.1051 0.0922 0.0865 1]
Show all properties
Use the ctf function to obtain the filter coefficients in the CTF format. The function also outputs the scale values.
[sosnum,sosden,sv] = ctf(sosFilt)
sosnum = 4×3
1 2 1
1 2 1
1 2 1
1 2 1
sosden = 4×3
1.0000 -1.2428 0.7575
1.0000 -1.0153 0.4359
1.0000 -0.8906 0.2595
1.0000 -0.8351 0.1810
sv = 5×1
0.1287
0.1051
0.0922
0.0865
1.0000
Create a dsp.AllpassFilter object and specify the allpass polynomial coefficients.
apFilt = dsp.AllpassFilter(AllpassCoefficients=[0 0.5539 0 0.2503;
0 -0.4364 0 0.2218;
0 0.3781 0 -0.3933])apFilt =
dsp.AllpassFilter with properties:
Structure: 'Minimum multiplier'
AllpassCoefficients: [3×4 double]
TrailingFirstOrderSection: false
Use the ctf function to obtain coefficients in the CTF format and the scale values.
[apnum,apden,sv] = ctf(apFilt)
apnum = 3×5
0.2503 0 0.5539 0 1.0000
0.2218 0 -0.4364 0 1.0000
-0.3933 0 0.3781 0 1.0000
apden = 3×5
1.0000 0 0.5539 0 0.2503
1.0000 0 -0.4364 0 0.2218
1.0000 0 0.3781 0 -0.3933
sv = 1
Create a dsp.FilterCascade object with these filter stages:
dsp.FIRFilterobjectdsp.SOSFilterobjectdsp.FourthOrderSectionFilterobjectdsp.IIRFilterobjectA scalar value of 3
Create a dsp.FIRFilter object using the designLowpassFIR function.
firFilt = designLowpassFIR(FilterOrder=8,SystemObject=true);
Create a dsp.SOSFilter object using the designLowpassIIR function.
sosFilt = designLowpassIIR(FilterOrder=8,HasScaleValues=true,...
SystemObject=true);Create a dsp.FourthOrderSectionFilter object. Specify the filter coefficients.
fosNum =[0.0135 0.0541 0.0812 0.0541 0.0135
0.0080 0.0319 0.0478 0.0319 0.0080];
fosDen =[1.0000 -2.2581 2.4552 -1.3108 0.3302
1.0000 -1.7257 1.1842 -0.3779 0.0470];
fosFilt = dsp.FourthOrderSectionFilter(fosNum,fosDen);Create a dsp.IIRFilter object. Specify the filter coefficients.
sosNum = [0.1287 0.2574 0.1287
0.1051 0.2103 0.1051
0.0922 0.1844 0.0922
0.0865 0.1729 0.0865];
sosDen = [1.0000 -1.2428 0.7575
1.0000 -1.0153 0.4359
1.0000 -0.8906 0.2595
1.0000 -0.8351 0.1810];
iirFilt = dsp.IIRFilter(sos2tf([sosNum,sosDen]));Cascade these filters into a single dsp.FilterCascade object using the cascade function.
filtCascadeObj = cascade(firFilt,cascade(sosFilt,fosFilt),...
3,iirFilt)filtCascadeObj =
dsp.FilterCascade with properties:
Stage1: [1×1 dsp.FIRFilter]
Stage2: [1×1 dsp.FilterCascade]
Stage3: 3
Stage4: [1×1 dsp.IIRFilter]
CloneStages: true
Use the ctf function to obtain the filter coefficients and scale values of the overall filter cascade in the CTF format.
[cascNum,cascDen,cascSV] = ctf(filtCascadeObj)
cascNum = 9×9
0.0000 0.0191 0.1019 0.2309 0.2963 0.2309 0.1019 0.0191 0.0000
1.0000 2.0000 1.0000 0 0 0 0 0 0
1.0000 2.0000 1.0000 0 0 0 0 0 0
1.0000 2.0000 1.0000 0 0 0 0 0 0
1.0000 2.0000 1.0000 0 0 0 0 0 0
0.0135 0.0541 0.0812 0.0541 0.0135 0 0 0 0
0.0080 0.0319 0.0478 0.0319 0.0080 0 0 0 0
3.0000 0 0 0 0 0 0 0 0
0.0001 0.0009 0.0030 0.0060 0.0076 0.0060 0.0030 0.0009 0.0001
cascDen = 9×5
1.0000 0 0 0 0
1.0000 -1.2428 0.7575 0 0
1.0000 -1.0153 0.4359 0 0
1.0000 -0.8906 0.2595 0 0
1.0000 -0.8351 0.1810 0 0
1.0000 -2.2581 2.4552 -1.3108 0.3302
1.0000 -1.7257 1.1842 -0.3779 0.0470
1.0000 0 0 0 0
1.0000 0.1000 0 0 0
cascSV = 10×1
1.0000
0.1287
0.1051
0.0922
0.0865
1.0000
1.0000
1.0000
1.0000
1.0000
Input Arguments
Digital filter, specified as one of these filter objects:
digitalFilter— Usedesignfiltto generate a digital filter based on frequency-response specifications.dsp.FIRFilter(DSP System Toolbox)dsp.IIRFilter(DSP System Toolbox)dsp.SOSFilter(DSP System Toolbox)dsp.FourthOrderSectionFilter(DSP System Toolbox)dsp.AllpassFilter(DSP System Toolbox)dsp.FilterCascade(DSP System Toolbox)
Output Arguments
Cascaded transfer function (CTF) coefficients, returned as a row vector or matrix.
B and A list the numerator and denominator
coefficients of the cascaded transfer function, respectively.
The sizes for B and A are
L-by-(m+1) and
L-by-(n+1), respectively. The function returns
the first column of A as 1, thus A(1) = 1 when
A is a row vector.
L represents the number of filter sections.
m represents the order of the filter numerators.
n represents the order of the filter denominators.
Each row of the B and A matrices contains the
respective polynomial coefficients of each CTF section.
For more information about the cascaded transfer function format and coefficient matrices, see Return Digital Filters in CTF Format.
Data Types: single | double
Scale values, returned as a scalar or a column vector of length L+1, where L is the number of filter sections. The scale values represent the distribution of the filter gain across the sections of the cascaded filter representation.
Data Types: single | double
More About
Partitioning an IIR digital filter into cascaded sections improves its numerical stability and reduces its susceptibility to coefficient quantization errors. The cascaded form of a transfer function H(z) in terms of the L transfer functions H1(z), H2(z), …, HL(z) is
Get the filter coefficients by specifying to return B and
A. That way, you can have digital filters in CTF format for analysis,
visualization and signal filtering.
When you specify to return the numerator and denominator coefficients in the CTF format, the L-row matrices B and A are returned as
such that the full transfer function of the filter is
where m ≥ 0 is the numerator order of the filter and n ≥ 0 is the denominator order.
Note
To filter signals using cascaded transfer functions, use the
ctffiltfunction.To analyze filters represented as cascaded transfer functions, use the Filter Analyzer app. You can also use these Signal Processing Toolbox™ functions to visualize and analyze filters in CTF format:
Time-Domain Responses —
impzlength,impz, andstepzFrequency-Domain Responses —
freqz,grpdelay,phasedelay,phasez,zerophase, andzplaneFilter Exploration —
filtord,islinphase,ismaxphase,isminphase, andisstable
References
[1] Lyons, Richard G. Understanding Digital Signal Processing. Upper Saddle River, NJ: Prentice Hall, 2004.
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)