Main Content

ztrans

Description

ztrans(f) finds the Z-Transform of f. By default, the independent variable is n and the transformation variable is z. If f does not contain n, ztrans uses symvar.

example

ztrans(f,transVar) uses the transformation variable transVar instead of z.

example

ztrans(f,var,transVar) uses the independent variable var and transformation variable transVar instead of n and z, respectively.

example

Examples

collapse all

Compute the Z-transform of sin(n). By default, the transform is in terms of z.

syms n
f = sin(n);
ztrans(f)
ans =
(z*sin(1))/(z^2 - 2*cos(1)*z + 1)

Compute the Z-transform of exp(m+n). By default, the independent variable is n and the transformation variable is z.

syms m n
f = exp(m+n);
ztrans(f)
ans =
(z*exp(m))/(z - exp(1))

Specify the transformation variable as y. If you specify only one variable, that variable is the transformation variable. The independent variable is still n.

syms y
ztrans(f,y)
ans =
(y*exp(m))/(y - exp(1))

Specify both the independent and transformation variables as m and y in the second and third arguments, respectively.

ztrans(f,m,y)
ans =
(y*exp(n))/(y - exp(1))

Compute the Z-transform of the Heaviside function and the binomial coefficient.

syms n z
ztrans(heaviside(n-3),n,z)
ans =
(1/(z - 1) + 1/2)/z^3
ztrans(nchoosek(n,2))
ans =
z/(z - 1)^3

Find the Z-transform of the matrix M. Specify the independent and transformation variables for each matrix entry by using matrices of the same size. When the arguments are nonscalars, ztrans acts on them element-wise.

syms a b c d w x y z
M = [exp(x) 1; sin(y) i*z];
vars = [w x; y z];
transVars = [a b; c d];
ztrans(M,vars,transVars)
ans =
[                (a*exp(x))/(a - 1),       b/(b - 1)]
[ (c*sin(1))/(c^2 - 2*cos(1)*c + 1), (d*1i)/(d - 1)^2]

If ztrans is called with both scalar and nonscalar arguments, then it expands the scalars to match the nonscalars by using scalar expansion. Nonscalar arguments must be the same size.

syms w x y z a b c d
ztrans(x,vars,transVars)
ans =
[ (a*x)/(a - 1),   b/(b - 1)^2]
[ (c*x)/(c - 1), (d*x)/(d - 1)]

Compute the Z-transform of symbolic functions. When the first argument contains symbolic functions, then the second argument must be a scalar.

syms f1(x) f2(x) a b
f1(x) = exp(x);
f2(x) = x;
ztrans([f1 f2],x,[a b])
ans =
[ a/(a - exp(1)), b/(b - 1)^2]

If ztrans cannot transform the input then it returns an unevaluated call.

syms f(n)
f(n) = 1/n;
F = ztrans(f,n,z)
F =
ztrans(1/n, n, z)

Return the original expression by using iztrans.

iztrans(F,z,n)
ans =
1/n

Input Arguments

collapse all

Input, specified as a symbolic expression, function, vector, or matrix.

Independent variable, specified as a symbolic variable. This variable is often called the "discrete time variable". If you do not specify the variable, then ztrans uses n. If f does not contain n, then ztrans uses the function symvar.

Transformation variable, specified as a symbolic variable, expression, vector, or matrix. This variable is often called the "complex frequency variable." By default, ztrans uses z. If z is the independent variable of f, then ztrans uses w.

More About

collapse all

Z-Transform

The Z-transform F = F(z) of the expression f = f(n) with respect to the variable n at the point z is

F(z)=n=0f(n)zn.

Tips

  • If any argument is an array, then ztrans acts element-wise on all elements of the array.

  • If the first argument contains a symbolic function, then the second argument must be a scalar.

  • To compute the inverse Z-transform, use iztrans.

Version History

Introduced before R2006a