This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Add patterns for the Z transform

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


ztrans::addpattern(pat, k, z, res, <vars, <conds>>)


ztrans::addpattern(pat, k, z, res) teaches ztrans to return .

The ztrans function uses a set of patterns for computing Z transforms. You can extend the set by adding your own patterns. To add a new pattern to the pattern matcher, use ztrans::addpattern. MuPAD® does not save custom patterns permanently. The new patterns are available in the current MuPAD session only.

Variable names that you use when calling ztrans::addpattern can differ from the names that you use when calling ztrans. See Example 2.

You can include a list of free parameters and a list of conditions on these parameters. These conditions and the result are protected from premature evaluation. This means that you can use not   iszero(a^2 - b) instead of hold( _not @ iszero )(a^2 - b).

The following conditions treat assumptions on identifiers differently:

  • a^2 - b <> 0 takes into account assumptions on identifiers.

  • not   iszero(a^2 - b) disregards assumptions on identifiers.

See Example 3.

Environment Interactions

Calling ztrans::addpattern changes the expressions returned by future calls to ztrans.


Example 1

Compute the Z transform of the function foo. By default, MuPAD does not have a pattern for this function:

ztrans(foo(k), k, z)

Add a pattern for the Z transform of foo using ztrans::addpattern:

ztrans::addpattern(foo(k), k, z, bar(z)):

Now ztrans returns the Z transform of foo:

ztrans(foo(k), k, z)

After you add a new transform pattern, MuPAD can use that pattern indirectly:

ztrans(foo(k + 3), k, z)

Example 2

Define the Z transform of foo(x) using the variables x and y as parameters:

ztrans::addpattern(x, x, y, y/(y^2-2*y+1)):

The ztrans function recognizes the added pattern even if you use other variables as parameters:

ztrans(s, s, t)

Example 3

Use assumptions when adding this pattern for the Z transform:

ztrans::addpattern(FOO(x*k), k, z, sin(1/(x - 1/2))*BAR(z),
                                     [x], [abs(x) < 1]):
ztrans(FOO(x*k), k, z) assuming -1 < x < 1

If |x| ≥ 1, you cannot apply this pattern:

ztrans(FOO(x*k), k, z) assuming x >= 1

If MuPAD cannot determine whether the conditions are satisfied, it returns a piecewise object:

ztrans(FOO(x*k), k, z)

Note that the resulting expression defining the Z transform of FOO(x*k) implicitly assumes that the value of x is not 1/2. A strict definition of the pattern is:

ztrans::addpattern(BAR(x*k), k, z, sin(1/(x - 1/2))*FOO(z),
                   [x], [abs(x) < 1, x <> 1/2]):

If either the conditions are not satisfied or substituting the values into the result gives an error, ztrans ignores the pattern. For this particular pattern, you can omit specifying the assumption x <> 1/2. If x = 1/2, MuPAD throws an internal “Division by zero.” error and ignores the pattern:




Arithmetical expression in the variable k representing the pattern to match


Identifier or indexed identifier used as a variable in the pattern


Identifier or indexed identifier used as a variable in the result


Arithmetical expression in the variable k representing the pattern for the result of the transformation


List of identifiers or indexed identifiers used as “pattern variables” (placeholders in pat and res). You can use pattern variables as placeholders for almost arbitrary MuPAD expressions not containing k or z. You can restrict them by conditions given in the optional parameter conds.


List of conditions on the pattern variables

Return Values

Object of type DOM_NULL

Was this topic helpful?