Understanding the Z-Plane - MATLAB
Video Player is loading.
Current Time 0:00
Duration 16:24
Loaded: 1.00%
Stream Type LIVE
Remaining Time 16:24
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
  • en (Main), selected
    Video length is 16:24

    Understanding the Z-Plane

    From the series: Control Systems in Practice

    Brian Douglas

    This tech talk covers how the z-domain (or the z-plane) relates to the s-domain and the time and frequency domains. It also walks through why the z-plane is a polar plot and how the recursion coefficients are the same as z-domain transfer function coefficients.

    Published: 7 May 2024

    In a previous video, we talked about the Z-transform, which is the way that we go from the discrete time domain to the Z-domain. In this video, let's talk a little bit about the Z-domain itself. In full disclosure, I had originally planned to explain why it's important for designing discrete systems, including filters. However, during my research for this, I discovered some outstanding videos by Youngmoo Kim and particularly one that captures the essence of everything that I wanted to say, and it does so brilliantly.

    So rather than reiterate his work, I'm going to cover other things, like how the Z-domain relates to other domains that you might be working with. And I want to walk through a few things that I find really interesting about it. And then afterwards, I recommend you go watch Youngmoo Kim's fantastic video that covers everything else. I'm Brian, and welcome to a MATLAB Tech Talk.

    To have a better understanding of domains and transforms in general, let's build up a simple map. We begin with the continuous time domain, which is where signals exist with values at every moment in time. And the counterpart to this is the discrete time domain, which has signals with values only at distinct separate points. And this is typical of digital signals or if you're plotting some kind of an intermittent process, like monthly temperature averages.

    Now, to convert a continuous time signal to a discrete time signal, we sample it at selected intervals. And conversely, to create a continuous signal from discrete data, we interpolate, filling in gaps where no data exists. And there are a lot of methods to do this interpolation, including holding the last known value constant, which is a zero-order hold, or linearly connecting points, which is a first-order hold. But again, there are a lot more than that.

    All right. So moving on, the continuous frequency domain represents signals through the magnitudes and phases of their constituent frequencies rather than time-based values. And we can go from the continuous time domain to the continuous frequency domain with the Fourier transform. And then we can go back again with its inverse.

    And similarly, the discrete frequency domain deals with signals at specific frequencies, not continuous frequencies. And the discrete Fourier transform allows movement between the discrete time and discrete frequency domains. And then its inverse brings you back again.

    We can also sample a continuous frequency signal to make it discrete, or I suppose interpolate a discrete frequency signal, but I'm not really sure how often this transformation is done, but it is possible. And we can also criss-cross between all of these domains with the discrete time Fourier transform and its inverse and the Fourier series. So we have lots of ways to move between these four different domains.

    Now, moving on, the continuous S-domain represents signals and systems by both frequency and exponential factors. This domain is particularly useful for depicting systems via transfer functions with poles and zeros. The Laplace transform and its inverse is the bridge between continuous time and the S-domain.

    In parallel, the discrete Z-domain mirrors the S-domain for discrete systems. The Z-transform and its inverse enable transitions between discrete time and the Z-domain. And direct conversions between the S-domain and the Z-domain are possible with the exact method of substituting Z for e to the ST, where T is the sample time of the discretization.

    And this is a nonlinear transform, which might not be ideal in all situations. So linear alternatives exist, like the bilinear transform. But these come with their own set of trade offs, such as warping in the Z-plane. And I have a video that covers that warping, which I've linked to below.

    All right. So this is how the Z-domain relates to all of these other important domains and how we move signals and systems between them. Now, for the rest of this video, we're going to focus on the Z-domain and cover two things that I find really interesting about it.

    The first interesting thing is that the Z-domain is not just a straight discretization of the S-domain, like we have with time and frequency. And what I mean by that is that to go from continuous time to discrete time, we just have to sample it. But that sampled signal is plotted on the same axis, and the overall shape of the signal is the same. It's just discrete.

    And this goes for frequency as well. A discrete frequency signal looks a lot like a sampled version of the continuous signal. Now, it might have slightly different values because the frequencies above the Nyquist frequency will be aliased down to something lower. But overall, the information is plotted in the same way with frequency along the horizontal axis and amplitude or power along the vertical axis.

    However, this is not the case going from the S-domain to the Z-domain. In addition to sampling the data, we're also representing that sampled data in a different format. The S-domain is a Cartesian, or rectangular plane, where the frequency content is plotted along the imaginary axis, and the exponential content is plotted along the real axis. Whereas with the Z-domain, it's a polar plane where frequency is plotted around the unit circle, and exponential content is plotted radially.

    Mathematically, the reason for this is because of how Z is defined. Z is equal to e to the ST, where T is the sample time, and S is a complex number representing the location in the S-plane. And when we perform this calculation, we get the corresponding point in the Z-domain.

    But why does this equation turn a rectangular plot into a polar one? Well, we can think of it this way. Since S has a real and imaginary component, this means that we can separate the equation into e raised to the real part of S times e raised to the imaginary part of S. And per Euler's formula, e raised to J omega T is cosine of omega T plus J sine of omega T. And this just traces a circle in the imaginary plane as you increase or decrease omega.

    Now, for the real component of S, e raised to a real number is just another real number, which means that this just scales the size of the circle. If sigma is 0-- that's the thick, black line over here-- then e raised to 0 is 1. And we get the unit circle. And that's the thick, black circle over here.

    But if the real component is negative or in the left half of the S-plane, then e raised to a negative number is smaller than 1. And the unit circle is scaled smaller. And if the real component is positive, then e to a positive number is greater than 1, and the unit circle is scaled larger.

    So the right half of the S-plane maps to the outside of the unit circle in the Z-plane. And we can get a feel for this transformation if I morph back and forth between the S-plane and the Z-plane. You can see the green portion start to wrap around the origin as all of the vertical lines bend into circles.

    And what's really cool about this sort of visualization is that we can start to get a feel for how poles and zeros move between the two domains and, therefore, what similar filters and systems look like in each. For example, let's look at a system that is a pure integrator. In the S-domain, the transfer function of an integrator is 1 over S. And even if you don't use transfer functions, this might be familiar to you if you use Simulink because 1 over S is the icon for the integrator block.

    Now, this doesn't mean that this block is actually integrating only using the S-domain. It works with all continuous domain signals. It's just that 1 over S is a nice shorthand way to indicate that this is an integrator.

    But anyway, in the S-plane, 1 over S means that there is a pole at the origin since as S approaches 0, this function goes to infinity, which is the definition of a pole. And there's a 0 way, way out at infinity, and this comes from the fact that as S approaches infinity, then the value of the transfer function approaches 0.

    Now, if we transform the S-plane into the Z-plane, we can see that the pole at the origin moves to Z equals 1. And the 0 at infinity gets pulled in and moves to Z equals 0. Therefore, we can say that the Z-domain transfer function of an integrator is Z over Z minus 1-- a 0 at the origin and a pole at Z equals 1.

    And now this is using positive powers of Z to represent the transfer function. But another form you often see is using negative powers of Z. It's the exact same equation, but in this format, it really makes it easy to interpret and implement in the time domain. But we're going to come back to that later in this video. The main takeaway here is that we have chosen to capture the information in a different format between the S and Z-planes.

    But that brings me to the second thing that I find interesting, and that is why this different representation. And there are at least two good reasons for this. And the first is because of the limited frequency information that we have when we're working with discrete systems or data. Continuous domains have an infinite number of frequencies, so we want the S-domain to stretch up and down forever to capture all of those frequencies. Whereas discrete domains only have frequency content up to the Nyquist frequency, up to half of the sampling rate.

    So if we kept a rectangular plane, we would have to cut it off above and below the Nyquist, which honestly doesn't sound too bad, right? I mean, we can't look at an infinite axis anyway, so who cares? Well, one issue comes in with aliasing.

    Let's say that there's a pole at some high frequency in the S-plane, and the sampling rate is such that it's above the Nyquist frequency. This information will be aliased down to a lower frequency during sampling. So we're moving all of that high-frequency information down into the band that we can see.

    But instead of thinking about it as moving high-frequency stuff down, it's helpful to think of frequency information as looping around the origin and just circling back on itself. For example, at 0 frequency, the pole would exist on the positive real axis. But as the frequency increases, we move around the origin until we get to the Nyquist frequency on the far left, and that's at half the sampling frequency.

    And then we just keep looping around. When we get to the sampling frequency, we've reached the same point on the positive real axis that we had at 0 frequency. So this means that a continuous domain frequency at the sampling rate will be aliased down to 0 Hertz when we move into the discrete domain. And then as we move up to higher frequencies, we can see where they're aliased down to since we're just continually looping around the origin over and over again.

    All right. Well, from a visualization perspective, that's pretty cool. But there's actually a more practical reason for defining the Z-plane in the way that we do for defining Z as e to the ST and not just Z as a discrete S. And that is because of how it makes implementing digital filters and digital controllers easier in software.

    The Z domain is a good way to represent systems for design and analysis because you can glean information about the system that you're working on just from looking at the poles and zeros. For example, if you're designing a recursive digital filter, you can use discrete transfer functions to understand things like the stability of your filter, or its frequency response, or impulse response. And then knowing that, you can add poles and zeros or move existing ones around to get a response that you're happy with.

    Now, while analysis and design is easy in the Z-domain, implementation is done in the time domain with software. So we need to take the inverse Z-transform of this transfer function to represent it as a difference equation that we can code, which might seem difficult at first, but because of how the Z-domain is defined, going back and forth between it and the time domain is actually rather trivial. And let me show you what I mean.

    Let's replace the coefficients in our transfer function with generic variables a and b. Now, to take the inverse Z-transform, we can expand out this polynomial. So what we end up with is this summation on the left equals this summation on the right. And now we can just take the inverse Z-transform of each of these terms individually.

    So that first term, y of z, just becomes y of k in the time domain, where k is the current sample time. The second term becomes b1 times y of k minus 1. And that k minus 1 is coming from the fact that there is a 1 over Z in the transfer function, which is equal to a unit delay.

    So in this case, we're looking at the output y delayed by one sample time. And we can keep going from there, where 1 over Z squared is delaying the output for two sample times. And now the same goes for the input u. Now we can rearrange our difference equation to get this.

    And here's how we can read this. It is the output of the filter at the current time step is equal to the scaled input at the current time step plus the scaled input from the last two sample times minus the scaled output from the last two sample times. And this is pretty straightforward to code, right? I mean, it's just buffering a few past data points and then scaling them and summing them together.

    And what's remarkable about this is that the coefficients in the time domain for the system are the exact same as the coefficients in the Z-domain, which makes implementation very easy. And similarly, if you're given a list of recursion coefficients, you can write out the transfer function directly. And then from there, you can check stability, and impulse response, and all of that great stuff that we use the Z-domain for. And this similarity in coefficients is a very useful property of the Z-domain and how it relates to the time domain.

    So now, with all of this information, we can go back to that integrator and interpret this transfer function. The transfer function is the output over the input, so I'll just say that the output is y, and the input is u. Now we can take the inverse Z-transform to get the difference equation. But since the coefficients are the same, we can just write this out directly as y of k minus y of k minus 1 equals u of k.

    Or if we rearrange it, we can see that the output of the integrator at sample time k is the new input plus the previous output. This function is just adding up all of the input values into a running total-- exactly what an integrator does. So that's pretty cool, right? That the properties of the Z-domain are such that we can easily interpret this function.

    OK, so that's all I really wanted to talk about in this video. I hope you have a little more appreciation for the Z-domain and maybe understand some of its quirks and benefits a little bit better. And I've also left a bunch of links below that you can check out to learn more about the Z-domain and filter design within MATLAB and Simulink if you are interested.

    All right. Don't forget to subscribe to this channel so that you don't miss any future Tech Talk videos. Also, you can find all of the existing Tech Talk videos across many different topics nicely organized at mathworks.com. And if you liked this video, then you might be interested to learn how we get to the Z-domain in our video on the Z-transform.

    All right. Thanks for watching, and I'll see you next time.