86 CHAPTER 3. FUNCTIONAL DESCRIPTION OF Xµ
spacing in the input signal pdm. This means that the input pdm must be regularly
spaced. Stair-case input functions with relatively few data points will often give
erroneous results. The input signal should be interpolated (with interp) before being
multiplied with the Dynamic System. The function defTimeRange will calculate a
default integration step size and form the required time vector. This can be useful in
creating an input pdm or as an input to interp. Note that the initial state is specified
within the Xmath Dynamic System.
Discrete time Dynamic Systems do not require an additional command as the time
increment is contained within the Dynamic System data object. The time step in the
input pdm must of course match the discrete system sample time.
Xmath also provides several core functions for common time response calculations: step
calculates the unit step response; impulse calculates the impulse response; and initial
calculates the unforced response from initial conditions specified within the Dynamic
System or provided as input arguments. In each of these functions the user may specify
a time to override the default selected by defTimeRange.
Time response calculations are illustrated in the following example. Several of the
functions discussed in the previous sections are also used.
# Create a second order lightly damped system.
sys = 5/makepoly([1,1,5],"s")
# Create an input signal with a step to +1 at
# 1 second and a step to -1 at 5 seconds. A
# 10 second signal is created.
u = gstep([0:0.05:10],[0;1;5],[0;1;-1])
# Calculate the time response.
y0 = sys*u
# Repeat this calculation with an initial
# condition of [-1;0]. Note that this is
# only meaningful for a specified realization
# and Xmath forces us to choose one. Here we
# choose that returned as the abcd default