Convert models between continuous time and discrete time and resample models in the Live Editor
To add the Convert Model Rate task to a live script in the MATLAB Editor:
On the Live Editor tab, select Task > Convert Model Rate.
In a code block in your script, type a relevant keyword, such as
convert
, rate
, or c2d
. Select
Convert Model Rate
from the suggested command
completions.
Model
— Model to convertSelect an LTI model. The list contains all suitable continuous-time or discrete-time dynamic system models in the MATLAB workspace, including:
Numeric LTI models such as tf
, ss
, or
zpk
models.
Identified LTI models such as idss
and idtf
.
(Using identified models requires a System Identification Toolbox™ license.)
You can convert SISO models or MIMO models, with or without time delays, although
some conversion methods are only available for SISO models (see the
Method parameter description). You cannot use
Convert Model Rate to convert generalized LTI models
such as genss
or uss
, frequency-response data
models such as frd
, or process models
(idproc
).
Sample Time
— Target sample timeSpecify the sample time of the converted model in units of
1/TimeUnit
, where TimeUnit
is the
TimeUnit
property of the input model.
To discretize a continuous-time model or resample a discrete-time model, enter the target sample time.
To convert a discrete-time model to continuous time, enter 0.
Method
— Rate conversion methodZero-order hold
(default) | First-order hold
| Bilinear (Tustin) approximation
| ...Choose a rate conversion method. Available methods are:
Zero-order hold
First-order hold
Impulse-invariant discretization
(continuous-to-discrete conversion of SISO models only)
Bilinear (Tustin) approximation
Zero-pole matching method
Least-squares method
(continuous-to-discrete
conversion of SISO models only)
For information about choosing a conversion method, see Continuous-Discrete Conversion Methods.
Delay Order
— Approximate order for estimating time delayWhen you convert the rate of a model that has a time delay, the
Bilinear (Tustin) approximation
or Zero-pole
matching method
methods round the time delay to the nearest integer
multiple of the sample time. This rounding can degrade the accuracy of dynamics,
especially near the Nyquist frequency.
Set Delay Order to a nonzero integer to make
Convert Model Rate approximate the fractional portion
of the delay using a Thiran filter, instead of rounding. Use the smallest value that
yields sufficiently accurate rate-converted dynamics for your application. For more
information about Thiran filters, see thiran
.
Prewarp Freq. (rad/s)
— Prewarp frequency for bilinear (Tustin) methodWhen you discretize a continuous-time model, if your system has important dynamics
at a particular frequency that you want the rate conversion to preserve, you can use the
Bilinear (Tustin) approximation
method with frequency
prewarping. This method ensures a match between the original and converted responses at
the prewarp frequency you specify. See Continuous-Discrete Conversion Methods.
Output Plot
— Type of response plotBode
(default) | Step
| Impulse
| ...Convert Model Rate automatically generates a response plot to help you check that the dynamics important to your application are preserved. Specify one of the following response plot types to compare the responses of the original and converted models while you experiment with conversion parameters.
Bode
Step
Impulse
Pole-Zero
The code generated by the task includes code to create the selected response plot.
To omit the response plot, select None
.