Open In App

How to Calculate the Impulse Response in MATLAB?

Last Updated : 09 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Impulse response δ(t) is defined as the output signal that is the result of applying an impulse to a system. The system could be signal filter as well. Physical understanding of the impulse response of a system is highly useful for understanding a dynamic system. In this article, we shall see how to calculate impulse of a digital filter and dummy dynamic systems using the in-built functionalities of MATLAB.
MATLAB provides following functions for calculating the impulse responses.

  1. impulse(system) – Calculates impulse response of a dynamically defined system.
  2. impz() – Calculates impulse response of digital filters.

Impulse Response of Dynamic Systems:

We will create state space of 2nd order in four variables using the ss() function of MATLAB. It must be noted that you must have one of the following installed for running this function:

  1. Control System Toolbox
  2. DPS system Toolbox
  3. Model Predictive Control Toolbox
  4. Signal Processing Toolbox

This is necessary as the state-space function is part of this products and not basic MATLAB. Now, we shall create a dummy system for illustration of the impulse() function. See the following example for the same.

Example 1:

Matlab




% MATLAB code for defining state variables
a = [-0.45572,-0.732814; 0.732814,0];
b = [-1, 1; 2 -3];
c = [0.2 -3.543];
  
% Creating state-space system using ss function.
sys = ss(a, b, c, 0);
  
% Calculating impulse response for the above system;
impulse(sys)


Output:

This would show the impulse response as a graphical signal.

Impulse response of a second order state-space system

 

Impulse Response of a Digital Filter:

As mentioned earlier, MATLAB provides functionality for calculating the impulse response of digital functions as well. For instance, we shall create a dummy fifth order elliptic filter from the Signal Processing Toolbox of MATLAB.

Example 2:

Matlab




% MATLAB code for Digital filter
[b,a] = ellip(5,0.23,23,0.55);
  
% Calculating impulse response
% with 75 sample points
impz(b,a,75)


Output:

This calculates impulse response at of the elliptic filter at fifth order for 75 sample points.

Impulse response for digital filter

 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads