realizemdl
Simulink subsystem block for filter
Description
realizemdl(
generates a model of filter System object™ in a Simulink® subsystem block using sum, gain, and delay blocks from Simulink. The properties and values of sysobj
)sysobj
define the
resulting subsystem block parameters.
realizemdl
requires Simulink. To accurately realize models of quantized filters, use Fixed-Point Designer™.
realizemdl(
generates the model for sysobj
,Name=Value
)sysobj
with additional options
specified by one or more Name-Value
pair arguments. Using
name-value pair arguments lets you control more fully the way the block subsystem
model gets built. You can specify such details as where the block goes, what the
name is, or how to optimize the block structure.
Examples
Realize Simulink Model of a Lowpass Butterworth Filter
d = fdesign.lowpass('N,F3dB',4,0.25); filterobject = design(d,'butter',Systemobject=true)
filterobject = dsp.SOSFilter with properties: Structure: 'Direct form II' CoefficientSource: 'Property' Numerator: [2x3 double] Denominator: [2x3 double] HasScaleValues: true ScaleValues: [0.1153 0.0886 1] Use get to show all properties
Create a new model, LPFilter.slx
, and realize the subsystem block in this model.
new_system('LPFilter');
realizemdl(filterobject);
View the block diagram by clicking on the subsystem block.
Create a new model, LPFilterMapping.slx
, and realize the subsystem block, with coefficients mapped to ports, in this model.
new_system('LPFilterMapping'); realizemdl(filterobject,MapCoeffsToPorts='on');
View the block diagram by clicking on the subsystem block.
In this case, the filter is an IIR filter with a direct form II second-order sections structure. Setting MapCoeffstoPorts to 'on' exports the numerator coefficients, the denominator coefficients, and the gains to the MATLAB® workspace using the default variable names Num, Den, and g. Each column of Num and Den represents one second-order section. You can modify the filter coefficients directly in the MATLAB workspace providing tunability to the realized Simulink model.
Input Arguments
sysobj
— Filter System object
filter System object
List of filter system objects that the function supports:
Name-Value Arguments
Example: d = fdesign.lowpass('N,F3dB',4,0.25); filterobject =
design(d,'butter',Systemobject=true);
realizemdl(filterobject,MapCoeffsToPorts='on');
Destination
— Destination choices
'current'
(default) | 'new'
| character vector | string scalar
Specify whether to add the block to your current Simulink model or create a new model to contain the block. If you
provide the name of a current subsystem as a character vector or a
string scalar, the realizemdl
function adds the new
block to the specified subsystem.
BlockName
— Name of the block
'filter'
(default) | character vector | string scalar
Provide the name for the new subsystem block. By default the block is named Filter.
MapCoeffsToPorts
— Map coefficients
'off'
(default) | 'on'
Specify whether to map the coefficients of the filter to the ports of the block.
MapStates
— Apply current filter states
'off'
(default) | 'on'
Specify whether to apply the current filter states to the realized
model. Such specification allows you to save states from a filter object
you may have used or configured in a specific way. The default setting
of 'off'
means the states are not transferred to the
model. Setting the property to 'on'
preserves the
current filter states in the realized model.
OverwriteBlock
— Overwrite existing block
'off'
(default) | 'on'
Specify whether to overwrite an existing block with the same name or create a new block.
OptimizeZeros
— Remove zero-gain blocks
'off'
(default) | 'on'
Specify whether to remove zero-gain blocks.
OptimizeOnes
— Replace unity-gain blocks
'off'
(default) | 'on'
Specify whether to replace unity-gain blocks with direct connections.
OptimizeNegOnes
— Replace negative unity-gain blocks
'off'
(default) | 'on'
Specify whether to replace negative unity-gain blocks with a sign change at the nearest sum block.
OptimizeDelayChains
— Replace delay chains
'off'
(default) | 'on'
Specify whether to replace delay chains made up of n unit delays with a single delay by n.
CoeffNames
— Names of coefficients
{'Num'}
(default FIR) | {'Num','Den'}
(default direct form IIR) | {'Num','Den','g'}
(default IIR SOS) | {'Num_1,'Num_2,'Num_3'...}
(default
multistage) | {'K'}
(default form lattice)
Specify the coefficient variable name as a cell array of character
vectors. MapCoeffsToPorts
must be set to
'on'
for this property to apply.
InputProcessing
— Possible input processing options
'columnsaschannels'
| 'elementsaschannels'
Specify sample-based ('elementsaschannels'
) or
frame-based ('columnsaschannels'
) processing.
RateOption
— Rate options
'enforcesinglerate'
(default) | 'allowmultirate'
Specify how the block adjusts the rate at the output to accommodate the reduced number of samples.
Dependencies
This parameter applies only when
InputProcessing
is
'columnsaschannels'
.
Arithmetic
— Value types
'double'
| 'single'
The arithmetic for System object inputs must be 'double'
or
'single'
.
Limitations
The destination must be a Simulink model. The function does not support a library file destination.
Version History
Introduced in R2011aR2024b: Support for dsp.VariableFIRDecimator
and dsp.VariableFIRInterpolator
Objects
Starting in R2024b, the realizemdl
analysis function supports
the dsp.VariableFIRDecimator
and dsp.VariableFIRInterpolator
objects.
R2024b: dsp.BiquadFilter
object warns
The dsp.BiquadFilter
object issues a warning and will be removed
in a future release. Use the dsp.SOSFilter
object instead. For more information on how to replace
your existing code, see the Compatibility Considerations
section in the dsp.BiquadFilter
reference page.
R2024b: Support for dsp.DCBlocker
object
Starting in R2024b, this function supports the dsp.DCBlocker
object.
R2023b: Support for dsp.ParallelFilter
and dsp.Delay
Objects
Starting in R2023b, the realizemdl
analysis function supports
the dsp.ParallelFilter
and the dsp.Delay
objects.
R2023b: dsp.BiquadFilter
object will be removed
The dsp.BiquadFilter
object will be removed in a future release.
Use the dsp.SOSFilter
object instead.
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi 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)