Updated March 4, 2023

## Introduction to Impulse Response Matlab

The following article provides an outline for Impulse Response Matlab. Impulse response δ(t) of a system is defined as the output signal that results when an impulse is applied to the system. The impulse response of a digital filter is the output that appears from the unit impulse sequence. Understanding the property of the system impulse response of the system and frequency response of the system is very important. Impulse response δ(t) calculates the unit impulse response of a dynamic system model. Impulse response assumes initial state values are zero for state-space models. Impulse response used “impulse(sys)” to plot of dynamic system. For Impulse Response of digital filter “impz” statement is used.

### Syntax

The syntax for Impulse Response (dynamic system) Matlab is as shown below:

`impulse(sys)`

`impulse(sys,t1)`

`impulse(sys1,sys2,...,sysN,t)`

`[y1,t1] = impulse(sys)`

`Y1 = impulse(sys,t1)`

`[y1,t1,x1,ysd] = impulse(sys)`

The syntax for Impulse Response (digital filter) Matlab is as shown below:

`[h1,t1] = impz(b1,a1)`

`[h1,t1] = impz(sos)`

`[h1,t1] = impz(d)`

`[h1,t1] = impz(`

**___**,n1,fs1)

### How to do Impulse Response Matlab?

In matlab Impulse Response uses an “impulse (sys)” statement for dynamic system and for digital filter “impz” is used.

The steps for Impulse Response for dynamic system:

**Step 1:**First input argument is taken in the variables.**Step 2:**Then we use “ss” statement.**Step 3:**Then we use “impulse (sys)” to plot the impulse response.

The steps for Impulse Response for digital filter system:

**Step 1:**First input argument is taken in the variables.**Step 2:**Then we defining a sample range for filter.**Step 3:**Then we use “impz” to calculating an impulse response of digital filter.**Step 4:**Use stem to plot the impulse response.

### Examples of Impulse Response Matlab

Given below are the examples :

#### Example #1

Let us see an example, in this example first we take a numerator and denominator of a system for numerator we use num1 notation and for denominator we use den1. In num1 we take coefficients are 0.9 -0.45 0.35 0.02 and in den1 we take coefficients are 1.0 0.71 -0.46 -0.62. And we are also defining a sample range into N1 variable, so N1 is equal to 50 that is 50 samples we need. Now calculate the impulse response the inbuilt function is available on Matlab that is impz, impz is used for calculating an impulse response of digital filter. So now we take impz (num1, den1, N1) and the response is stored in y1 variable. Now for plotting a graph we use a stem function, stem is used to plot a discrete time signal. So we take an n2 variable for mentioning a range of x axis that is samples so we take range from 0 to 50 with the difference with 1. So now we take stem (n2, y1),where n2 is a samples numbers and y1 is stored the impulse response. Now this we get a plot of impulse response.

**Code:**

`clc;`

clear all;

close all;

N1 = 50;

num1 = [0.9 -0.45 0.35 0.02];

den1 = [1.0 0.71 -0.46 -0.62];

y1 = impz (num1, den1, N1);

n2 = 0 : N1-1;

stem(n2, y1);

title ('Impulse Response of Digital Filter');

**Output:**

** **

#### Example #2

Let us see an example, in this example we plot a 2^{nd} order state – space model. We take a 4 variables a1, b1, c1 and d1 this are Nx– by-Nx real- or complex-valued matrix. In our example the a1 is [-0.55, -0.78; 0.78, 0], b1 is a [1, -2; 0, 2], c1 is a [1.96, 6.44] and value of d1 is zero. And these 4 variables are passed from ss function, ss is a state space model. sys2 = ss (a1,b1,c1,d1) creates the discrete-time state-space model object of the following form: x[n+1]=a1x[n]+b1u[n] and y[n]=c1x[n]+d1u[n]. And this assign to sys2. And then we plot the response using an impulse function, impulse is used to plot a response of dynamic system. And we store an impulse response result into an y1 and t1 variable, for this we take command as [y1, t1] = impulse (sys2), the impulse returns the output response in a y1 variable and the time vector in a t1 variable these two variables are used for simulation. And the size of y1 is displayed on command window using a size function, size (y1). And because of impulse function the response is displayed.

**Code:**

`clc;`

close all;

clear all;

a1 = [-0.55, -0.78; 0.78,0];b1 = [1,-2;0,2];c1 = [1.96, 6.44];d1 = 0;sys2 = ss(a1, b1, c1, d1);impulse (sys2)[y1, t1] = impulse (sys2);size (y1)grid on

**Output:**

** **

The impulse response of the first input channel is shown in left plot, and the impulse response of the second input channel is shown in right plot.

### Conclusion

In this article we saw the concept related to impulse response matlab. Basically impulse response is used to plot of dynamic system. Then saw syntax related to impulse response matlab statements and how it is used in matlab code. Also we saw some examples related to impulse response Matlab statement.

### Recommended Articles

This is a guide to Impulse Response Matlab. Here we discuss the introduction, how to do impulse response matlab? and examples respectively. You may also have a look at the following articles to learn more –