ctf2sysobj
R2026bSyntax
Description
creates a System object™ from a cascaded transfer function (CTF) with numerator coefficients
ctfFiltObj = ctf2sysobj(Num,Den)Num and denominator coefficients Den.
also uses the scale values ctfFiltObj = ctf2sysobj(Num,Den,g)g of a digital filter.
uses additional options specified in the name-value arguments. Use this syntax with any of
the input arguments in previous syntaxes.ctfFiltObj = ctf2sysobj(___,Name=Value)
Examples
Since R2026b
Consider a second-order FIR filter with the numerator coefficients [1 2 1]. Convert this filter to a filter System object™ using the ctf2sysobj function.
You can implement the filter as an FIR filter, second-order section (SOS) filter, fourth-order section (FOS) filter, or as an arbitrary-order IIR filter. By default, the ctf2sysobj function creates a dsp.FIRFilter System object.
filtObjFIR = ctf2sysobj([1 2 1],1)
filtObjFIR =
dsp.FIRFilter with properties:
Structure: 'Direct form'
NumeratorSource: 'Property'
Numerator: [1 2 1]
InitialConditions: 0
Show all properties
To create other filters, specify the filter type in the FilterTypes argument.
Create an SOS filter by setting the FilterTypes argument to "sos".
filtObjSOS = ctf2sysobj([1 2 1],1,FilterTypes="sos")filtObjSOS =
dsp.SOSFilter with properties:
Structure: 'Direct form II transposed'
CoefficientSource: 'Property'
Numerator: [1 2 1]
Denominator: [1 0 0]
HasScaleValues: false
Show all properties
Create an IIR filter by setting the FilterTypes argument to "iir".
filtObjIIR = ctf2sysobj([1 2 1],1,FilterTypes="iir")filtObjIIR =
dsp.IIRFilter with properties:
Structure: 'Direct form II transposed'
Numerator: [1 2 1]
Denominator: 1
InitialConditions: 0
Show all properties
Since R2026b
Consider a set of CTF coefficients with mixed orders.
First row is an FIR filter of order 4.
Second row is a scalar value.
Third row is a SOS filter.
Last row is an allpole filter of order 4.
Num = [1 2 1 3 4;
17 0 0 0 0
1 2 1 0 0;
1 0 0 0 0];
Den = [1 0 0 0 0;
12 0 0 0 0
1 0 2 0 0;
1 -3 2 -1 0];Convert these CTF coefficients to a filter System object using the ctf2sysobj function.
Allow all filter types by setting the FilterTypes argument to "all". The function opts to use a dsp.FIRFilter object for the first row, a scalar for the second row, and the dsp.FourthOrderSectionFilter object for the last two rows. The function cascades these filter objects as individual stages of the dsp.FilterCascade object.
filtObjCasc = ctf2sysobj(Num,Den,FilterTypes="all")filtObjCasc =
dsp.FilterCascade with properties:
Stage1: [1×1 dsp.FIRFilter]
Stage2: 1.4167
Stage3: [1×1 dsp.FourthOrderSectionFilter]
CloneStages: true
Implement this filter as a single fourth-order section filter by setting the FilterTypes argument to "fos".
filtObjFOS = ctf2sysobj(Num,Den,FilterTypes="fos")filtObjFOS =
FourthOrderSectionFilter with properties:
Numerator: [4×5 double]
Denominator: [4×5 double]
RoundingMethod: 'Floor'
OverflowAction: 'Wrap'
CoefficientsDataType: [1×1 embedded.numerictype]
AccumulatorDataType: 'Inherit: Inherit via internal rule'
OutputDataType: 'Inherit: Same as input'
You can also avoid the fourth-order section filter implementation and specify other types explicitly. The function then creates a dsp.FilterCascade object with the other filter types.
filtObj = ctf2sysobj(Num,Den,FilterTypes=["fir","scalar","allpole","sos"])
filtObj =
dsp.FilterCascade with properties:
Stage1: [1×1 dsp.FIRFilter]
Stage2: 1.4167
Stage3: [1×1 dsp.SOSFilter]
Stage4: [1×1 dsp.AllpoleFilter]
CloneStages: true
To omit the scalar, remove the "scalar" option from the FilterTypes argument list. The function then implements the scalar stage with a dsp.FIRFilter object.
filtObjNoScalar = ctf2sysobj(Num,Den,FilterTypes=["fir","allpole","sos"])
filtObjNoScalar =
dsp.FilterCascade with properties:
Stage1: [1×1 dsp.FIRFilter]
Stage2: [1×1 dsp.FIRFilter]
Stage3: [1×1 dsp.SOSFilter]
Stage4: [1×1 dsp.AllpoleFilter]
CloneStages: true
Since R2026b
When more than one filter implementation is possible for a given set of coefficients, the ctf2sysobj function implements the filter based on the hierarchy discussed in the Filter Implementation Hierarchy section.
Consider a 3-tap FIR filter with the coefficients [1 2 1]. This filter can be implemented as an FIR filter, second-order section filter, fourth-order section filter, or an IIR filter.
Allow all filter types. The function opts for the FIR implementation as its first choice.
filtObj = ctf2sysobj([1 2 1],1,FilterTypes="all")filtObj =
dsp.FIRFilter with properties:
Structure: 'Direct form'
NumeratorSource: 'Property'
Numerator: [1 2 1]
InitialConditions: 0
Show all properties
Exclude "fir" from the filter types list. The function chooses the second-order section filter implementation.
filtObjNoFIR = ctf2sysobj([1 2 1],1,FilterTypes=["sos","fos","iir"])
filtObjNoFIR =
dsp.SOSFilter with properties:
Structure: 'Direct form II transposed'
CoefficientSource: 'Property'
Numerator: [1 2 1]
Denominator: [1 0 0]
HasScaleValues: false
Show all properties
Exclude the "sos" implementation. The function chooses "fos" and implements a dsp.FourthOrderSectionFilter object.
filtObjNoSOS = ctf2sysobj([1 2 1],1,FilterTypes=["fos","iir"])
filtObjNoSOS =
FourthOrderSectionFilter with properties:
Numerator: [1 2 1 0 0]
Denominator: [1 0 0 0 0]
RoundingMethod: 'Floor'
OverflowAction: 'Wrap'
CoefficientsDataType: [1×1 embedded.numerictype]
AccumulatorDataType: 'Inherit: Inherit via internal rule'
OutputDataType: 'Inherit: Same as input'
Exclude "fos". The function implements an IIR filter.
filtObjIIR = ctf2sysobj([1 2 1],1,FilterTypes="iir")filtObjIIR =
dsp.IIRFilter with properties:
Structure: 'Direct form II transposed'
Numerator: [1 2 1]
Denominator: 1
InitialConditions: 0
Show all properties
If you specify "allpole" or "scalar" instead of the other filter types, the function errors out because these two options do not work for the CTF coefficients [1 2 1].
Design a sixth-order bandpass elliptic filter. Obtain the numerator and denominator coefficients in CTF format. The size of the filter coefficients matrices indicate three fourth-order sections.
[Num,Den] = ellip(6,3,50,[0.3 0.6],"bandpass","ctf")
Num = 3×5
0.2275 -0.0435 -0.1999 -0.0435 0.2275
0.2275 -0.1070 0.1733 -0.1070 0.2275
0.2275 -0.1188 0.2423 -0.1188 0.2275
Den = 3×5
1.0000 -0.6236 1.6521 -0.5161 0.6936
1.0000 -0.5779 1.3890 -0.5327 0.8714
1.0000 -0.5568 1.2684 -0.5468 0.9715
Convert the filter in the CTF format to a System object. The ctf2sysobj function returns a dsp.FourthOrderSectionFilter object.
ctfObj = ctf2sysobj(Num,Den)
ctfObj =
FourthOrderSectionFilter with properties:
Numerator: [3×5 double]
Denominator: [3×5 double]
RoundingMethod: 'Floor'
OverflowAction: 'Wrap'
CoefficientsDataType: [1×1 embedded.numerictype]
AccumulatorDataType: 'Inherit: Inherit via internal rule'
OutputDataType: 'Inherit: Same as input'
Visualize the magnitude response of the System object and of the filter representation in numerator and denominator coefficients. Both filter representations give the same magnitude response. The filter is in normalized frequency units.
fa = filterAnalyzer(ctfObj); addFilters(fa,Num,Den)
Specify an absolute sample rate for the filter using the SampleRate argument.
ctfObjAbsSampleRate = ctf2sysobj(Num,Den,SampleRate=22050)
ctfObjAbsSampleRate =
FourthOrderSectionFilter with properties:
Numerator: [3×5 double]
Denominator: [3×5 double]
RoundingMethod: 'Floor'
OverflowAction: 'Wrap'
CoefficientsDataType: [1×1 embedded.numerictype]
AccumulatorDataType: 'Inherit: Inherit via internal rule'
OutputDataType: 'Inherit: Same as input'
Visualize the magnitude response of the filter in absolute frequency units.
filterAnalyzer(ctfObjAbsSampleRate)
To change the sample rate after constructing the object, use the setInputSampleRate function.
setInputSampleRate(ctfObjAbsSampleRate,44100) filterAnalyzer(ctfObjAbsSampleRate)

Define a CTF numerator array for a cascade of two FIR filters of order 100. Convert the cascade of filters to a System object.
Num = [designLowpassFIR(FilterOrder=100); ...
designHighpassFIR(FilterOrder=100)];
Hsys = ctf2sysobj(Num)Hsys =
dsp.FilterCascade with properties:
Stage1: [1×1 dsp.FIRFilter]
Stage2: [1×1 dsp.FIRFilter]
CloneStages: true
Customize the conversion from CTF to System object and add filter cascade stages.
Design an eight-order Butterworth peak IIR filter. The number of columns in the filter coefficients, B and A, indicate that the peak filter is divided in second-order sections. The vector of scale values, g, contains the gain for the four stages and the overall system gain.
[B,A,g] = designNotchPeakIIR(FilterOrder=8, ...
QualityFactor=5,HasScaleValues=true)B = 4×3
1.0000 2.0000 1.0000
1.0000 -2.0000 1.0000
1.0000 2.0000 1.0000
1.0000 -2.0000 1.0000
A = 4×3
1.0000 0.2738 0.8880
1.0000 -0.2738 0.8880
1.0000 0.1067 0.7455
1.0000 -0.1067 0.7455
g = 5×1
0.1479
0.1479
0.1380
0.1380
1.0000
Convert the filter coefficients to a System object.
sosSys = ctf2sysobj(B,A,g)
sosSys =
dsp.SOSFilter with properties:
Structure: 'Direct form II transposed'
CoefficientSource: 'Property'
Numerator: [4×3 double]
Denominator: [4×3 double]
HasScaleValues: true
ScaleValues: [5×1 double]
Show all properties
By default, the ctf2sysobj function generates a dsp.SOSFilter System object for IIR filters of the order 2 or less. To generate a dsp.FilterCascade System object, specify the ForceCascade name-value argument as true. You can add filter stages in the next step.
Convert the filter coefficients to a dsp.FilterCascade System object.
ctfSys = ctf2sysobj(B,A,g,ForceCascade=true)
ctfSys =
dsp.FilterCascade with properties:
Stage1: [1×1 dsp.SOSFilter]
CloneStages: true
Add two stages to the dsp.FilterCascade System object. The stages comprise an allpass filter and a polyphase FIR sample-rate conversion filter. Display the System object. The resulting dsp.FilterCascade System object has three stages.
addStage(ctfSys, dsp.AllpassFilter) addStage(ctfSys, dsp.FIRRateConverter(3,2,triang(9))) ctfSys
ctfSys =
dsp.FilterCascade with properties:
Stage1: [1×1 dsp.SOSFilter]
Stage2: [1×1 dsp.AllpassFilter]
Stage3: [1×1 dsp.FIRRateConverter]
CloneStages: true
Plot the impulse response discrete-time Fourier transform (DTFT) of the three-stage dsp.FilterCascade System object.
freqzmr(ctfSys)

Input Arguments
CTF numerator coefficients, specified as a matrix, vector, or scalar.
Num must be of size
L-by-(m + 1), where:
L represents the number of filter sections.
m represents the order of the filter numerators.
For more information about the CTF format and coefficient matrices, see Specify Digital Filters in CTF Format.
Data Types: single | double
Complex Number Support: Yes
CTF denominator coefficients, specified as a matrix, vector, or scalar.
Den must be of size
L-by-(n + 1), where:
L represents the number of filter sections.
n represents the order of the filter denominators.
For more information about the CTF format and coefficient matrices, see Specify Digital Filters in CTF Format.
Note
If any element of Den(:,1) is not equal to
1, then ctf2sysobj normalizes the filter
coefficients by Den(:,1). In this case,
Den(:,1) must be nonzero.
Data Types: single | double
Complex Number Support: Yes
Scale values, specified as a real-valued scalar or as a real-valued vector with L + 1 elements, where L is the number of filter sections. The scale values represent the distribution of the filter gain across sections of the cascaded filter representation.
Depending on how you specify g, ctf2sysobj
applies a gain to the filter sections using the scaleFilterSections function:
Scalar —
ctf2sysobjdistributes the gain uniformly across all filter sections.Vector —
ctf2sysobjapplies the first L gain values to the corresponding filter sections and distributes the last gain value uniformly across all filter sections.
Data Types: single | double
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: ctfFiltObj = ctf2sysobj([2 4 2;1 0 0],ForceCascade=true)
specifies an FIR digital filter with option to wrap each filter stage into System object.
Since R2026b
Type of filter to implement, specified as one of these:
'all'— All available filter types. The function picks a filter type based on the format of the CTF coefficients and the filter implementation hierarchy.If the coefficients allow all filter types, the function uses
"fir"as the first choice."fir"— FIR filter implemented as adsp.FIRFilterobject."allpole"— Allpole filter implemented as adsp.AllpoleFilterobject. The leading denominator coefficient of the allpole filter must be 1 and the numerator is always 1."sos"— Second-order section filter implemented as adsp.SOSFilterobject."fos"— Fourth-order section filter implemented as adsp.FourthOrderSectionFilterobject."iir"— IIR filter implemented as adsp.IIRFilterobject."scalar"— Scalar gain implemented as one or more stages in thedsp.FilterCascadeobject.Cell array or string array of filter types — You can specify multiple allowable filter types as a string array or a cell array. For example, [
"fir","iir","sos"] or {"fir","iir","sos"}. If the CTF coefficients support more than one specified filter type, the function uses the filter implementation hierarchy to determine which filter to implement. For an example, see Convert CTF Coefficients with Non-Unique Implementations to System Object.
Example: ["fir","iir","sos"],
{"fir","iir","sos"}
Data Types: char | string
Option to force single-stage cascades into a dsp.FilterCascade
System object, specified as one of these:
false(0) —ctf2sysobjreturns each filter stage as one of these formats:dsp.SOSFilter— Second-order sections (SOS) format.dsp.FourthOrderSectionFilter— Fourth-order sections (FOS) format.dsp.IIRFilter— Infinite impulse response (IIR) filter format.dsp.FIRFilter— Finite impulse response (FIR) filter format.
true(1) —ctf2sysobjwraps and returns each stage into adsp.FilterCascadeobject.Single-stage
dsp.FilterCascadeobject, for filters in SOS and FOS format.Multiple-stage
dsp.FilterCascadeobject, for FIR and IIR filters in CTF format.
Data Types: logical
Option to treat column vectors (Num and
Den) as row vectors (single-stage CTF), specified as on these values:
true(1) — When you specifyNumandDenas column vectors,ctf2sysobjassumes thatNumandDenlist the coefficients of a single-stage filter.false(0) — When you specifyNumandDenas column vectors,ctf2sysobjassumes that each row ofNumandDenrelates to a separate filter stage.To specify
ParseColumnVectorsAsRowsasfalse(0), you must specifyNumandDenas vectors with the same number of rows andDenmust end with nonzero elements.
Data Types: logical
Since R2026a
Input sample rate of the filter object, specified as one of these:
Positive real scalar — The input sample rate of the filter object is a positive real scalar.
"normalized"— The input sample rate of the filter object is in normalized frequency units.
Data Types: single | double | char | string
Output Arguments
CTF filter System object, returned as one of these System objects:
dsp.SOSFilter— Second-order sections (SOS)dsp.FourthOrderSectionFilter— Fourth-order sections (FOS)dsp.IIRFilter— Infinite impulse response (IIR) filterdsp.FIRFilter— Finite impulse response (FIR) filterdsp.FilterCascade— Cascade ofdsp.SOSFilter,dsp.FourthOrderSectionFilter.dsp.IIRFilteranddsp.FIRFilterSystem objects
The ctf2sysobj identifies filter stages (SOS, FOS, IIR, or
FIR) from the coefficients specified in Num and
Den.
While an SOS or FOS filter stage can have multiple sections, each IIR or FIR filter stage has one section.
The order of each filter stage (stage order) is the maximum between the numerator order and denominator order.
When more than one filter implementation is
possible for a given set of CTF coefficients, the ctf2sysobj
function uses the filter implementation
hierarchy to select the filter type. (since R2026b)
Depending on the number of stages, maximum order of each stage, and the value
specified in ForceCascade, ctf2sysobj returns
one of the System objects in this table.
| Stage Impulse Response Type | Stage Order |
(Single-stage CTF) |
(Multiple-stage CTF) |
(Single-stage and multiple-stage CTF) |
|---|---|---|---|---|
| IIR | 1 or 2 | dsp.SOSFilter | Does not apply | Single-stage dsp.FilterCascade |
| IIR | 3 or 4 | dsp.FourthOrderSectionFilter | Does not apply | Single-stage dsp.FilterCascade |
| IIR | Greater than 4 | dsp.IIRFilter | dsp.FilterCascade | dsp.FilterCascade |
| FIR | Any | dsp.FIRFilter | dsp.FilterCascade | dsp.FilterCascade |
| Combination of the above | Does not apply | dsp.FilterCascade | dsp.FilterCascade | |
More About
Filter implementation is not always unique. For example, any second-order section filter is also a fourth-order section filter, and fourth-order section filter is a special case of an IIR filter. An allpole filter is also a special case of an IIR filter.
When more than one filter implementation is possible for a given set of CTF
coefficients, the ctf2sysobj function uses the following filter
implementation hierarchy to select the filter type. For example, if you set
FilterTypes to ["fir", "sos"],
and the CTF coefficients can be implemented using both the filter types, the function
chooses "sos" and implements a dsp.SOSFilter object.
Similarly, if a set of CTF coefficients can be implemented using both the
"allpole" and "sos" filter types, the function
chooses "allpole" and creates a dsp.AllpoleFilter
object. If you set FilterTypes to "all", and the CTF
coefficients satisfy all filter types, the function prefers "fir".
Here is the filter implementation hierarchy.
"scalar" → "fir" → "allpole" →
"sos" → "fos" → "iir"
For an example, see Convert CTF Coefficients with Non-Unique Implementations to System Object.
This table lists the default filter implementation for each filter type. For each row of
the CTF coefficients that you specify, the ctf2sysobj function
identifies the filter type from this table, and then selects the closest implementation from
the filter types specified in the FilterTypes argument.
| Filter Type | Description | Default Filter Implementation |
|---|---|---|
| Scalar gain | Scalar stage of |
| FIR filter of any order |
|
| Allpole filter of any order. The leading denominator coefficient must be 1. The numerator is always 1. |
|
| Second-order IIR filter |
|
| Fourth-order IIR filter |
|
| Higher order IIR filter |
|
| Any of the above | Uses the filter implementation hierarchy |
Version History
Introduced in R2025aYou can now specify the type of filter to implement in the
ctf2sysobj function using the new FilterTypes
argument.
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)