You are on page 1of 3

INC4061: 디지털신호처리 실습자료 (2010-02)

실습 6 Difference equation

1. 목적

Matlab 을 이용하여 difference equation 을 그래프로 나타내어 본다.

2. 준비

An LTI discrete system can also be described by a linear constant coefficient difference
equation of the form
∑ ∑ , (1)
If , then the difference equation is of order N. This equation describes a recursive
approach for computing the current output, given the input values and previously computed
output values. In practice this equation is computed forward in time, from ∞ to
∞. Therefore another form of this equation is
∑ ∑ (2)
A solution to this equation can be obtained in the form

The homogeneous part of the solution, , is given by

Where , ,…, are N roots (also called natural frequencies) of the characteristic
equation

This characteristic equation is important in determining the stability of system. If the roots
satisfy the condition
| | 1, 1, … ,
Then a causal system described by (2) is stable. The particular part of the solution, ,
is determined from the right-hand side of (1). In Chapter 4 we discuss the analytical
approach of solving difference equations using the z-transform.

Digital Image Processing using Matlab page 29

DML
INC4061: 디지털신호처리 실습자료 (2010-02)

3. FILTER and IMPZ function

-filter finction

A function called filter is available to solve difference equations numerically, given the input
and the difference equation coefficients. In its simplest form this function is invoked by

y = filter(b,a,x);

where

b = [b0, b1, …, bM]; a = [a0, a1, …, aN];

are the coefficient arrays from the equation given in (2), and x is the input sequence array.
The output y has the same length as input x. One must ensure that the coefficient a0 not be
zero.

-impz funxtion

To compute and plot impulse response, MATLAB provides the function impz. Then invoked
by

h = impz(b,a,n);

it computes samples of the impulse response of the filter at the sample indices given in n
with numerator coefficients in b and denominator coefficients in a. When no output
arguments are given, the impz function plots the response in the current figure window
using the stem function. We will illustrate the use of these functions in the following
example.

DML
INC4061: 디지털신호처리 실습자료 (2010-02)

4. Example

Given the following difference equation

. ;

a. Calculate and plot the impulse response h(n) at n=-20,…,100.


b. Calculate and plot the unit step response s(n) at n = -20,…,100.
c. Is the System specified by h(n) stable?

% making stepseq (unit step) function

function [x,n] = stepseq(n0,n1,n2)


% Generates x(n) = u(n-n0); n1 <= n,n0 <= n2
% ------------------------------------------
% [x,n] = stepseq(n0,n1,n2)
%
if ((n0 < n1) | (n0 > n2) | (n1 > n2))
error('arguments must satisfy n1 <= n0 <= n2')
end
n = [n1:n2];
%x = [zeros(1,(n0-n1)), ones(1,(n2-n0+1))];
x = [(n-n0) >= 0];

DML

You might also like