**How to Obtain an Impulse Response**

Once a transform (or transfer function) G(s) has been deﬁned in MATLAB, operations can be performed to compute and display the corresponding time function g(t), known as the inverse Laplace transform. If the poles are known, G(s) can be written as a partial-fraction expansion from which the individual transform terms can be associated with time functions. MATLAB provides the function **residue** for computing the poles and their corresponding residues in a partial-fraction expansion, from which we can obtain g(t) in analytical form. Alternatively, using the property that g(t) is the unit-impulse response corresponding to G(s), the Control System Toolbox function** impulse** can be directly applied to obtain g(t) in numerical form, from which it can be plotted.

**Impulse Response Matlab Example**

Find the partial-fraction expansion and g (t)

The transfer function of a ﬁxed linear system is

\[G(s)=\frac{3s+2}{2{{s}^{3}}+4{{s}^{2}}+5s+1}\]

Create the transfer function in MATLAB and determine its poles and zeros. Perform a partial-fraction expansion of G(s), and plot the Impulse response of the system.

**Solution**

The transfer function is implemented by deﬁning the row vectors **numG = [3 2]** and **denG = [2 4 5 1]**, which contain the coefﬁcients of the numerator and denominator polynomials, respectively, as indicated in Script 2. To obtain the zeros, poles, and gain of G(s), we enter **[zG, pG, kG] = tf2zp (numG, denG)**. Doing this, we ﬁnd that G(s) has a zero at s = -0.6667 and poles at s = -0.2408 and -0.8796± j1.1414, and the gain is 3/2 = 1.50. Thus we can write the transfer function in factored form as

\[G(s)=\frac{1.5(s+0.6667)}{(s+0.2408)(s+0.8796-j1.1414)(s+0.8796+j1.1414)}\]

To write G(s) in a partial-fraction expansion, we use the residue command as in **[resG,polG, otherG] = residue (numG, denG)** . The result is a column vector resG containing the residue at each of the poles of G(s), a column vector polG containing the poles, and a scalar otherG consisting of a constant that will be non-empty only if the degree of the numerator of G(s) equals the degree of the denominator. Doing this, we obtain the poles and residues given in Table 1.

**Table.1: Poles and residues of G(s) in Example**

Pole |
Residue |

-0.2408 | 0.3734 |

-0.8796 +j1.1414 | -0.1867 -j0.5526 |

-0.8796 -j1.1414 | -0.1867 + j0.5526 |

The third result produced by the residue command is the scalar otherG, which has no value because there are no other terms in the expansion. Thus MATLAB sets it to [ ], which is referred to as the empty element.

From these MATLAB results we can write the partial-fraction expansion of the transfer function as

\[G(s)=\frac{0.3734}{s+0.2408}+\frac{-0.1867-j0.5526}{s+0.8796-j1.1414}+\frac{-0.1867+j0.5526}{s+0.8796+j1.1414}\]

**Impulse Response Function Plot using Matlab**

The impulse response can be computed by using the impulse command, which can take one of the several different forms. The simplest of these is to enter** impulse (numG, denG)**, which will cause a plot of g (t) to be displayed using a time interval selected by MATLAB.

Another option is to enter **impulse (numG, denG, time)** where time is a column vector of time points that has been deﬁned previously.

A third option is to use a single left-hand argument as in **y = impulse (numG, denG, time)** with the time vector speciﬁed as before. This form of the command will return the output values for each time point in the column vector y, which can then be plotted versus time by entering **plot (time, y)**.

The corresponding impulse response for above example appears in Figure 1.

**Matlab Code for Calculating Partial-fraction Expansion and Impulse Response**

% Script 2 : Matlab Code for calculating Partial-fraction expansion and Impulse Response clear all;close all;clc numG = [3 2], denG =[2 4 5 1] % create G(s) from numerator & denomerator [zG,pG,kG]=tf2zp(numG,denG) %zeros, poles, & gain of G(s) [resG,polG,otherG] = residue(numG,denG) % residues & poles of G(s) impulse(numG,denG) %impulse response

**Result**

**Comment:** If the degree of the numerator of G(s) is the same as the degree of its denominator, the otherG part of the result of the residue command will be a constant which represents an impulse component in g(t). While the residue command returns this value correctly, the impulse command will not include it in the response. It is up to the user to keep track of nonempty otherG part of a partial-fraction expansion.

**What IF?**

Try changing the coefficients of the numerator of G(s) while leaving the denominator alone. Look at the effects on the poles, zeros, gain, residues, and impulse response. You should find that all of the above are affected except the poles. Looked at another way, by changing the numerator of G(s) but not it’s denominator, you are affecting the weight of the system’s mode functions but not the mode functions themselves.