This example shows how to upsample a system
using both the
and compares the results of both to the original system.
Upsampling a system can be useful, for example, when you need to implement a digital controller at a faster rate than you originally designed it for.
Create the discrete-time system with a sample time of 0.3 s.
G = tf([1,0.4],[1,-0.7],0.3);
Resample the system at 0.1 s using
G_d2d = d2d(h1,0.1)
G_d2d = z - 0.4769 ---------- z - 0.8879 Sample time: 0.1 seconds Discrete-time transfer function.
d2d uses the zero-order-hold
(ZOH) method to resample the system. The resampled system has the
same order as
Resample the system again at 0.1 s, using
G_up = upsample(h1,3)
G_up = z^3 + 0.4 --------- z^3 - 0.7
The second input, 3, tells
upsample to resample
a sample time three times faster than the sample time of
This input to
upsample must be an integer.
G_up has three times as many poles and zeroes
Compare the step responses of the original model
the resampled models
The step response of the upsampled model
exactly the step response of the original model
The response of the resampled model
only at every third sample.
Compare the frequency response of the original model with the resampled models.
In the frequency domain as well, the model
upsample command matches the original
model exactly up to the Nyquist frequency of the original model.
upsample provides a better match than
both the time and frequency domains. However,
the model order, which can be undesirable. Additionally,
only available where the original sample time is an integer multiple
of the new sample time.