How to Get Ramp Input Response in MATLAB

Ammar Ali Feb 02, 2024
How to Get Ramp Input Response in MATLAB

This tutorial will introduce how to plot the step and ramp response of a closed-loop system using the step() and lsim() function in MATLAB.

Plot the Step and Ramp Response Using the step() and lsim() Function in MATLAB

You can find the step and ramp response of a closed-loop system using the control system toolbox. This toolbox offers many functions like the tf() function, which is used to define the transfer function of the system, the feedback() function to define the feedback of the system, the step() function to plot the step response of the system, and the lsim() function to plot the ramp response of the system. For example, let’s define a transfer function of a closed-loop system and then use the step() and lsim() function to plot the step and ramp response of the closed-loop system. See the code below.

t = 1:0.01:2;
tranferFunction = tf(2, [3 2]);
G = feedback(tranferFunction, 2);
step(G)
lsim(G,t,t)

Output:

Plotting Step and Ramp response of a closed loop system

In the above code, you can change the time vector and the transfer function according to your requirements. Check this link for more details about the tf() function.

Author: Ammar Ali
Ammar Ali avatar Ammar Ali avatar

Hello! I am Ammar Ali, a programmer here to learn from experience, people, and docs, and create interesting and useful programming content. I mostly create content about Python, Matlab, and Microcontrollers like Arduino and PIC.

LinkedIn Facebook

Related Article - MATLAB Plot