Tools for Manipulating Transfer Functions.
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Most of the packages for manipulating transfer functions are much better at manipulating transfer functions that are specified as ratios of polynominals in z rather than z^{-1}. For example, using the shift-and-scaling identity for the Z transform, we would transform the difference equation
As long as z is not zero, we can rewrite H(z) as
In MATLAB, you can manipulate discrete-time transfer functions using z if, at the beginning of your session you type:
>> z = tf([1 0], [1], -1)
The above command informs matlab that z is a discrete-time transfer function. BE SURE TO INCLUDE THE -1 IN THE tf() COMMAND, IT INFORMS MATLAB THAT THIS IS A Discrete-Time TRANSFER FUNCTION with a GENERIC sample period. You can also replace the -1 with 0.001 if you only plan to consider one millisecond sample periods. And if you do, then the x-axis for your plots will be time in seconds, rather than sample indices. For example, if \Delta T = 0.001, use
>> z = tf([1 0], [1], 0.001)
Once you have specified that z is a transfer function, arithmetic operations involving z will also produce transfer functions. For example, if you type:
>> Gamma = 10; dt = 0.001; Hsys1 = Gamma * dt * dt * (1/(z-1))*(1/(z-1))
Matlab will respond with the following:
Hsys1 =
1e-05
-------------
z^2 - 2 z + 1
Sample time: unspecified
Discrete-time transfer function.
We are often interested in how increasing overall controller gain affect the transfer function of the closed-loop feedback system:

where in this case, H(z) = H_{sys1}(z) above, K(z) = K_0 K_n(z) where K_0 is a scalar representing overall controller gain and K_n(z) is a normalized controller. Black's formula yields the closed-loop transfer function, G, where
To plot the poles (or natural frequencies) of G as a function the scalar gain K_0, assuming K_n(z) = 1 in the above formula, in MATLAB type
>> rlocus(Hsys1)
and you will see the root locus below.

If you defined z using tf
as above, then you can use z
to define a PD controller transfer function. For example, consider proportional and delta (aka derivative) gains, denoted Kp
and Kd
respectively, for a PD controller representerd by the difference equation relating error, e[n] to actuator command, c[n],
To generate a MATLAB transfer function for a PD controller with specific values of K_p and K_d, type, for example
>> Kp = 1.0; Kd = 0.5; Kpd = Kp + Kd/dt * (z-1)/z;
To determine the closed-loop transfer function G for the feedback system with controller K_{pd} and plant H_{sys1} , we can execute the matlab command
>> G = feedback(Kpd*Hsys1,1)
and see a plot of the closed-loop step response with the command
>> step(G);
If you specified a sample interval when defining z using the tf command, For discrete-time systems specified using a GENERIC sample rate, -1, in the example near the top of the page, matlab's step function assumes a sample period of one second. Our sample period is one millisecond, so you can interpret the time axis as being in milliseconds.
Instead, if you specified the real sample interval in the tf command, then you can set plot intervals using real time. For example,
>> step(G,5);
will plot 5 samples if you used -1 to define z using the tf command, and will plot 5000 samples, or five seconds, if you used 0.001 in the tf command.
Note that feedback(Kpd * Hsys1,1)
,with 1 as the second argument, returns the closed-loop transfer function for what we often refer to as a tracking feedback system. That is, the matlab function feedback returns a transfer function that is equivalent to
>> G = (Kpd*Hsys1)/(1+Kpd*Hsys1)
but the returned transfer function would not be identical to the result from the
If we are given dt = 0.001 and Gamma = 10, suppose we set Kp = 1 (to normalize for the root locus plot), and guess at a good value for Kd (maybe start with 0.2, but for this problem you don't know what "we" selected), and then type
>> Kd = 0.2, Kp = 1.0, dt = 0.001; Gamma = 10; Hsys1 = Gamma*dt*dt*(1/(z-1))*(1/(z-1)); Kpd = Kp + Kd/dt*(z-1)/(z); rlocus(Kpd*Hsys1);
Can we determine the value of K_d from looking a the resulting root locus plot? Not really, because the important details are crowded around the point z = 1. If you do not see the plot, try typing Matlab's show graph command:
>> shg
We can focus on the details around z=1 by using the command
>> rlocus(Kpd*Hsys1, linspace(0,10,1000))
which plots the poles for the closed-loop system
By looking at the root locus, and zooming in as in the figure below, you can see enough important details to estimate the value of K_d, to at least one digit (try redrawing the zoomed-in root locus plot for K_d = 0.3, 0.4, ...).
What value of K_d yields a root-locus plot matching the one shown in the screenshot above.
Suppose we consider adding an additional pole to our model for the system, that is,
>> Hsys1p = ((1-0.95)/(z-0.95))*Hsys1;
We can then compare the impact of the new system model using matlab's rlocus command, as the command takes multiple transfer functions. That is, we can compare the root locuses for the two cases with
>> rlocus(Kpd*Hsys1, Kpd*Hsys1p, linspace(0,10,1000))
The zoomed in root locus for the plot is shown below (from matlab), please use it to answer the questions below the figure. You will have to use trial and error with K_d again.
Using K_p = 1 and K_d equal to the value you just found when comparing the two loci, let's consider what happens when we scale both K_p and K_d by K_0 . In particular, what is the maximum value for this scale factor, K_0, so that the closed-loop system involving Hsys1 has the same frequency of ringing in its step-response as the closed-loop system involving Hsys1p (to within five percent).
Trial and error, with an educated guess at the good trial values, is about the only way to find K_0, so do not worry about getting K_0 to better than to better than 5 percent. You may find it helpful to use the matlab command
>> pole(G)
and look at the imaginary parts (be sure to type "pole", do NOT make it plural).
Suppose the location of the extra pole 0.98, closer to one, which we can generate with the matlab command
>> Hsys1p = ((1-0.98)/(z-0.98))*Hsys1;
For this slower system, we expect worse ringing, and therefore we expect a lower maximum for K_0, but by how much?
One might wonder why root locus plots are given so much importance. They trace the natural frequencies of the feedback system as a function of a single scale factor K_0, but a PD controller has two gains, a PID controller three. Why is one particular plot of natural frequencies versus scale factor so important, and why should it be the one that maintains gain ratios? For example, why not plot the natural frequencies of a feedback system as a function of K_0 given a controller with a fixed proportional gain,