Chuyển đến nội dung

Bài 9 · Discrete Signals

The z-Transform Basics

Learn the z-transform, transfer functions H(z), poles and zeros, stability, and how the frequency response comes from the unit circle, with Python checks against SciPy.

Convolution and difference equations describe a system in the time domain. The z-transform turns both into algebra. Convolution becomes multiplication, a delay becomes multiplication by z^-1, and a filter becomes a ratio of two polynomials. From that ratio you can read off the stability and the frequency response by looking at where its roots lie.

Definition

The z-transform of a sequence x[n] is

X(z) = sum over n of x[n] * z^(-n)

where z is a complex variable. Each sample becomes a coefficient of a power of z^-1. For the finite sequence [2, -1, 4] at n = 0, 1, 2, we get X(z) = 2 - z^-1 + 4 z^-2.

Three rules do most of the work:

Operation in time Effect on X(z)
Delay x[n-k] multiply by z^-k
Sum a x1 + b x2 a X1(z) + b X2(z)
Convolution x * h X(z) * H(z)

A few useful pairs: the impulse d[n] has transform 1; the one-sided exponential a^n u[n] has transform 1 / (1 - a z^-1) (valid for |z| > |a|); the delay d[n-k] has z^-k.

The transfer function

Apply the rules to the general difference equation from the previous lesson. With Y(z) = H(z) X(z):

H(z) = (b0 + b1 z^-1 + ... + bM z^-M) / (1 + a1 z^-1 + ... + aN z^-N)

So H(z) = B(z) / A(z), built directly from the coefficient arrays b and a that you pass to lfilter. The inverse transform of H(z) is the impulse response h[n].

flowchart LR
    A["difference equation<br/>coefficients b, a"] --> B["H(z) = B(z) / A(z)"]
    B --> C["poles and zeros"]
    B --> D["frequency response<br/>z = e^(jw)"]
    B --> E["impulse response h[n]"]

One compact object gives the stability, the frequency response and the impulse response.

Python Polynomial multiplication is convolution

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Poles and zeros

Factor the numerator and denominator:

H(z) = b0 * (1 - q1 z^-1)(1 - q2 z^-1)... / ((1 - p1 z^-1)(1 - p2 z^-1)...)

  • The zeros q are values of z where H(z) = 0: the filter blocks these.
  • The poles p are where H(z) becomes infinite: they create resonance and memory.

NumPy finds them as polynomial roots. Note that np.roots expects coefficients in powers of z (not z^-1), so for H(z) with equal-length numerator and denominator the arrays b and a can be passed directly, and for different lengths pad with zeros to the same length first.

Python Poles and zeros of a filter

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Stability

A causal LTI system is stable if and only if all poles lie strictly inside the unit circle (|p| < 1). Zeros can be anywhere. A pole on the circle gives a sustained oscillation (marginal), and outside the circle the response grows without bound. FIR filters have poles only at z = 0, so they are always stable.

Python Check stability from the poles

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Frequency response from the z-plane

The z-transform evaluated on the unit circle z = e^(j*w) is the frequency response H(e^(jw)). As w runs from 0 to pi we walk along the upper half of the circle from the frequency 0 point z = 1 to the Nyquist point z = -1. A pole near the circle makes the response large nearby; a zero on the circle makes it exactly zero there.

The magnitude |H| is the gain at each frequency, and the angle of H is the phase shift. Computing it by hand is just plugging z^-1 = e^(-jw) into the polynomials.

Python Frequency response by hand versus freqz

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

scipy.signal.freqz(b, a, worN) does the same and is what you will use. With fs given (freqz(b, a, fs=1000)), the frequency axis comes back in hertz.

Poles, zeros and the shape of the response

A geometric rule helps design: the gain at a frequency w is proportional to the product of distances from e^(jw) to the zeros divided by the product of distances to the poles. So:

  • Put a zero at a frequency you want to kill (a hum at 50 Hz).
  • Put a pole just inside the circle at a frequency you want to boost (a resonance).
  • Keep every pole inside the circle.
Python A notch filter from one pair of zeros and poles

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The gain at 50 Hz falls to a very large negative number (a deep notch), while the rest of the spectrum is close to 0 dB because the pole sits next to the zero and cancels its effect at other frequencies.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. A delay of k samples corresponds to which operation on X(z)?

    x[n-k] has transform z^-k X(z); that is why z^-1 is drawn as a delay block.
  2. 2. When is a causal LTI system with transfer function B(z)/A(z) stable?

    Poles with magnitude below 1 give decaying terms p^n; zeros do not matter for stability.
  3. 3. The frequency response is the z-transform evaluated at:

    Setting z = e^(jw) gives the gain and phase for a sinusoid of digital frequency w.
  4. 4. Where must you put a zero to completely block a frequency w0?

    H(e^(jw0)) = 0 only if the numerator vanishes at that point on the circle.

Summary

  • X(z) = sum x[n] z^-n; a delay multiplies by z^-1, and convolution becomes multiplication.
  • H(z) = B(z)/A(z) comes straight from the difference-equation coefficients.
  • Zeros block frequencies; poles create resonance; stability needs all poles inside the unit circle.
  • The frequency response is H(z) at z = e^(jw), computed by scipy.signal.freqz.
  • Pole-zero placement is a practical design tool (a notch filter needs one zero pair and one pole pair).

Next: Fourier Series and Complex Exponentials

Theo dõi tiến độ của bạn

Tạo tài khoản miễn phí để đánh dấu bài đã học và tiếp tục từ chỗ bạn dừng lại trên mọi thiết bị.