# 13: Discrete-Time Systems in the Time-Domain

- Page ID
- 96279

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

\( \newcommand{\Span}{\mathrm{span}}\)

\( \newcommand{\id}{\mathrm{id}}\)

\( \newcommand{\Span}{\mathrm{span}}\)

\( \newcommand{\kernel}{\mathrm{null}\,}\)

\( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\)

\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\)

\( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)

\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)

\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vectorC}[1]{\textbf{#1}} \)

\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)- Discrete-time systems allow for mathematically specified processes like the difference equation.

A discrete-time signal \(s(n)\) is **delayed** by \(n_0\) samples when we write \(s(n-n)0)\) with \(n_0>0\). Choosing \(n_0\) to be negative advances the signal along the integers. As opposed to analog delays, discrete-time delays can **only** be integer valued. In the frequency domain, delaying a signal corresponds to a linear phase shift of the signal's discrete-time Fourier transform:

\[s(n=-n_{0}\leftrightarrow e^{-(i2\pi fn_{0})}S(e^{i2\pi f}) \nonumber \]

**Linear** discrete-time systems have the superposition property.

\[S\left ( a_{1}x_{1}(n)+a_{2}x_{2}(n) \right )=a_{1}S\left ( x_{1}(n) \right )+a_{2}S\left ( x_{2}(n) \right ) \nonumber \]

A discrete-time system is called **shift-invariant** (analogous to time-invariant analog systems) if delaying the input delays the corresponding output. If

\[S\left ( x(n) \right )=y(n) \nonumber \]

Then a shift-invariant system has the property

\[S\left ( x(n-n_{0}) \right )=y(n-n_{0}) \nonumber \]

We use the term shift-invariant to emphasize that delays can only have integer values in discrete-time, while in analog signals, delays can be arbitrarily valued.

We want to concentrate on systems that are both linear and shift-invariant. It will be these that allow us the full power of frequency-domain analysis and implementations. Because we have no physical constraints in "constructing" such systems, we need only a mathematical specification. In analog systems, the differential equation specifies the input-output relationship in the time-domain. The corresponding discrete-time specification is the **difference equation**.

\[y(n)=a_{1}y(n-1)+...+a_{p}y(n-p)+b_{0}x(n)+b_{1}x(n-1)+...+b_{q}x(n-q) \nonumber \]

Here, the output signal \(y(n)\) is related to its **past** values

\[y(n-1),l=\left \{ 1,...,p \right \} \nonumber \]

and to the current and past values of the input signal \(x(n)\). The system's characteristics are determined by the choices for the number of coefficients \(p\) and \(q\) and the coefficients' values

\[\left \{ a_{1},...,a_{p} \right \}\; and\; \left \{ b_{0},b_{1},...,b_{q} \right \} \nonumber \]

There is an asymmetry in the coefficients: where is \(a_0\)? This coefficient would multiply the \(y(n)\) term in the above equation. We have essentially divided the equation by it, which does not change the input-output relationship. We have thus created the convention that \(a_0\) is always one.

As opposed to differential equations, which only provide an **implicit** description of a system (we must somehow solve the differential equation), difference equations provide an **explicit** way of computing the output for any input. We simply express the difference equation by a program that calculates each output from the previous output values, and the current and previous inputs.

Difference equations are usually expressed in software with **for** loops. A MATLAB program that would compute the first 1000 values of the output has the form ` for n=1:1000 y(n) = sum(a.*y(n-1:-1:n-p)) + sum(b.*x(n:-1:n-q)); end `

An important detail emerges when we consider making this program work; in fact, as written it has (at least) two bugs. What input and output values enter into the computation of **y(1)**? We need values for **y(0), y(-1),...,** values we have not yet computed. To compute them, we would need more previous values of the output, which we have not yet computed. To compute these values, we would need even earlier values, ad infinitum. The way out of this predicament is to specify the system's **initial conditions**: we must provide the **p** output values that occurred before the input started. These values can be arbitrary, but the choice does impact how the system responds to a given input. **One** choice gives rise to a linear system: Make the initial conditions zero. The reason lies in the definition of a linear system: The only way that the output to a sum of signals can be the sum of the individual outputs occurs when the initial conditions in each case are zero.

The initial condition issue resolves making sense of the difference equation for inputs that start at some index. However, the program will not work because of a programming, not conceptual, error. What is it? How can it be "fixed?"

**Solution**

The indices can be negative, and this condition is not allowed in MATLAB. To fix it, we must start the signals later in the array.

Let's consider the simple system having \(p = 1\) and \(q = 0\).

\[y(n)=ay(n-1)+bx(n) \nonumber \]

To compute the output at some index, this difference equation says we need to know what the previous output **y(n-1)** and what the input signal is at that moment of time. In more detail, let's compute this system's output to a unit-sample input:

\[x(n)=\delta (n) \nonumber \]

Because the input is zero for negative indices, we start by trying to compute the output at **n = 0**.

\[y(0)=ay(-1)+b \nonumber \]

What is the value of **y(-1)**? Because we have used an input that is zero for all negative indices, it is reasonable to assume that the output is also zero. Certainly, the difference equation would not describe a linear system if the input that is zero for **all** time did not produce a zero output. With this assumption, **y(-1) = 0**, leaving **y(0) = b**. For **n > 0**, the input unit-sample is zero, which leaves us with the difference equation

\[\forall n,n> 0:\left ( y(n)=ay(n-1) \right ) \nonumber \]

We can envision how the filter responds to this input by making a table.

\[y(n)=ay(n-1)+b\delta (n) \nonumber \]

n | x(n) | y(n) |
---|---|---|

-1 | 0 | 0 |

0 | 1 | b |

1 | 0 | ba |

2 | 0 | ba^{2} |

: | 0 | : |

n | 0 | ba^{n} |

Coefficient values determine how the output behaves. The parameter **b **can be any value, and serves as a gain. The effect of the parameter **a **is more complicated (see Table above). If it equals zero, the output simply equals the input times the gain **b**. For all non-zero values of **a**, the output lasts forever; such systems are said to be **IIR** (**I**nfinite **I**mpulse **R**esponse). The reason for this terminology is that the unit sample also known as the impulse (especially in analog situations), and the system's response to the "impulse" lasts forever. If **a **is positive and less than one, the output is a decaying exponential. When **a = 1**, the output is a unit step. If **a **is negative and greater than **-1**, the output oscillates while decaying exponentially. When **a = -1**, the output changes sign forever, alternating between **b **and **-b**. More dramatic effects when **|a| > 1**; whether positive or negative, the output signal becomes larger and larger, **growing** exponentially.

Positive values of

Note that the difference equation

\[y(n)=a_{1}y(n-1)+...+a_{p}y(n-p)+b_{0}x(n)+b_{1}x(n-1)+...+b_{q}x(n-q) \nonumber \]

does not involve terms like \(y(n+1)\) or \(x(n+1)\) on the equation's right side. Can such terms also be included? Why or why not?

**Solution**

Such terms would require the system to know what future input or output values would be before the current value was computed. Thus, such terms can cause difficulties.

A somewhat different system has no **"a"** coefficients. Consider the difference equation

\[y(n)=\frac{1}{q}\left ( x(n)+...+x(n-q+1) \right ) \nonumber \]

Because this system's output depends only on current and previous input values, we need not be concerned with initial conditions. When the input is a unit-sample, the output equals

\[\frac{1}{q}\; for\; n=\left \{ 0,...,q-1 \right \} \nonumber \]

then equals zero thereafter. Such systems are said to be **FIR** (**F**inite **I**mpulse **R**esponse) because their unit sample responses have finite duration. Plotting this response (Figure \(\PageIndex{2}\):) shows that the unit-sample response is a pulse of width **q **and height **1/q**. This waveform is also known as a boxcar, hence the name **boxcar filter** given to this system. We'll derive its frequency response and develop its filtering interpretation in the next section. For now, note that the difference equation says that each output value equals the **average** of the input's current and previous values. Thus, the output equals the running average of input's previous **q** values. Such a system could be used to produce the average weekly temperature (**q = 7**) that could be updated daily.

## Contributor

- ContribEEOpenStax