Control Tutorials for MATLAB and Simulink (2024)

The step function is one of most useful functions in MATLAB for control design. Given a system representation, the response to a step input can be immediately plotted, without need to actually solve for the time response analytically. A step input can be described as a change in the input from zero to a finite value at time t = 0. By default, the step command performs a unit step (i.e. the input goes from zero to one at time t = 0). The basic syntax for calling the step function is the following, where sys is a defined LTI object.



  • Changing the magnitude of the step
  • Specifying the time scale
  • Saving the response
  • Step response of discrete-time systems

This command will produce a series of step response plots, all on the same figure. A plot will be made for each input and output combination. Most systems you will come across in the beginning will be SISO or Single-Input, Single-Output. In this case, there will be only one plot generated. However, the step command can also accept MIMO, Multiple-Input, Multiple-Output, systems.

For example, suppose you want to model a mechanical system consisting of a mass, spring, and damper, with an applied force. You can derive the transfer function shown below. You wish to see what the system response to unit step input is (an applied force of 1N). To model this, enter the following code into a new m-file. Running this script in the MATLAB command window will generate a plot like the one shown below.

 M = 1; % units of kg K = 10; % units of N/m B = 2; % units of N-s/m num = 1; den = [M B K]; sys = tf(num,den) step(sys);
sys = 1 -------------- s^2 + 2 s + 10 Continuous-time transfer function.

Control Tutorials for MATLAB and Simulink (1)

This figure shows the output response, which is the position of the mass. You can see that in steady-state the mass has moved 0.1 meters (the spring force balances the applied force). The system is underdamped and has overshoot.

Further details regarding the use of the step command for more advanced situations are given below.

Changing the magnitude of the step

So far, we have only dealt with unit step inputs. Suppose the input to our system was not 1 Newton, but in fact 100 Newtons. The step command can accommodate this by multiplying the system by 100 (since we are only dealing with linear systems). For the example above, this is achieved with the following code, which generates the plot shown below.


Control Tutorials for MATLAB and Simulink (2)

The plot looks similar to the one above it except that it has been scaled vertically by a factor of 100.

Specifying the time scale

The step response for any LTI object can be plotted with a user-supplied time vector. This vector will specify the time interval over which the step response will be calculated. If the vector is spaced at small time intervals, the plot will look smoother. Specifcally, a specified time vector can be supplied via the second input to the function as shown below.


In the above two plots, only the first 6 seconds of the response are shown. Suppose that the first 10 seconds need to be displayed. A time vector can be created to compute the step response over this range. Adding the following commands to your m-file and running will generate the figure shown below.


Control Tutorials for MATLAB and Simulink (3)

As you can see, the plot goes for 10 seconds.

Saving the response

The final note about the step command is that all of the above variations can be used with lefthand arguments. There are two ways to invoke the lefthand arguments, depending on whether or not the time vector was supplied to the step command.

[y,t] = step(sys);


[y,t] = step(sys,t);

If the system is in state-space form, then the time histories of the internal states can also be returned.

[y,t,x] = step(sys);

The y vector contains the output response. It has as many columns as outputs and as many rows as elements in the time vector, t. The x vector contains the state response. It has as many columns as states and as many rows as elements in the time vector, t. When used with lefthand arguments, no plot is drawn when the step function is called. You will usually want to put a semicolon after the step command when you invoke it with lefthand arguments; otherwise, MATLAB will print out the entire output, state, and time vectors to the command window. You can plot the output response using plot(t,y) and the state response using plot(t,x).

Step response of discrete-time systems

If the system under consideration is a discrete-time system, step will plot the output as piecewise constant. If the sampling time is unspecified, the output time scale will be in samples. If the sampling time is specified, the time scale will be in seconds. Consider the following example.

num = 1;den = [1 0.5];Ts = 0.1;sys = tf(num,den,Ts)step(sys)
sys = 1 ------- z + 0.5 Sample time: 0.1 secondsDiscrete-time transfer function.

Control Tutorials for MATLAB and Simulink (4)

Published with MATLAB® 9.2

Control Tutorials for MATLAB and Simulink (2024)


Is MATLAB Simulink hard to learn? ›

Although Matlab is not considered to be a programming language, it really is easy to learn. When you write code on Matlab you actually don't care about declaring data types, allocating memories e.t.c like you do in other programming languages.

What does it mean when MATLAB says not enough input arguments? ›

your function needs to be called with at least three input arguments. Therefore you must call it with exactly three input arguments. From the text of the error message you're likely calling it with fewer than three input arguments.

Is MATLAB good for control systems? ›

As a control systems engineer, you can use MATLAB® and Simulink® at all stages of development, including plant modeling, controller design, deployment with automatic code generation, and system verification.

How can I improve my MATLAB skills? ›

You ARE interested in improving your skills AT MATLAB.
  1. Read the tutorials. They seem reasonable enough.
  2. Find a project that interests you, and try to solve small problems in that area. If there is no project that interests you, then why are you bothering to learn MATLAB? ...
  3. Learn to use vectors. ...
Feb 13, 2015

Is MATLAB harder than Python? ›

The OOP in MATLAB is more advanced and complex, which to some can be more confusing. That being said, MATLAB is generally a more advanced language while Python is more of a beginner's language. Therefore, just because MATLAB may be more complex and confusing at first, with practice, it will become easier to grasp.

What is the salary of MATLAB Simulink engineer? ›

Matlab Simulink Developer salary in India ranges between ₹ 2.9 Lakhs to ₹ 15.0 Lakhs with an average annual salary of ₹ 5.0 Lakhs. Salary estimates are based on 47 latest salaries received from Matlab Simulink Developers.

Is MATLAB enough for a job? ›

Conclusion. The industry has some familiar buzz that learning MATLAB will not be a good opportunity for a better career. But this is not fully true. Yes, it is an acceptable reason that salary or company structure will never be able to touch available popular jobs on other programming technologies.

Which engineers use MATLAB the most? ›

Mechanical engineers of Design and manufacturing field use MATLAB and Simulink heavily. You would be surprised to know that MATLAB also forms the based for different CAD software as well as designing software just like SOLIDWORKS.

Is MATLAB or Python better for machine learning? ›

In general, Python is preferred for larger and more complex machine learning projects due to its scalability and the availability of a wide range of libraries and frameworks. Python is also the preferred choice for deep learning due to its support for popular deep learning frameworks such as TensorFlow and PyTorch.

What is the weakness of MATLAB? ›

Disadvantage of MATLAB

This comparatively high cost is more than offset by the decreased time necessary for an engineer or scientist to create a working program, so MATLAB is cost-effective for businesses. However, it is too expensive for most individuals to consider purchasing.

How long does it take to master MATLAB? ›

If you're a novice programmer, you can expect it to take a little longer than if you were a more seasoned programmer. Someone who can afford to devote all their time to MATLAB can finish learning the language in two weeks. If you have a lot of other responsibilities, however, it will take you longer to complete.

Is MATLAB a valuable skill? ›

Beyond engineering, you can pursue several careers where MATLAB is a valuable skill. Research scientists, data scientists, data analysts, and machine learning professionals all benefit from having MATLAB as part of their repertoire.

How long does it take to learn MATLAB Simulink? ›

If you're a novice programmer, you can expect it to take a little longer than if you were a more seasoned programmer. Someone who can afford to devote all their time to MATLAB can finish learning the language in two weeks. If you have a lot of other responsibilities, however, it will take you longer to complete.

Is Simulink better than MATLAB? ›

Another factor to consider when choosing between Simulink blocks and MATLAB code is the speed and efficiency of your system. Simulink blocks can be faster and more efficient for some tasks, such as prototyping, testing, and debugging.

Is MATLAB easy to learn for beginners? ›

MATLAB® creates an environment where issues and resolutions are expressed in familiar mathematical notation. MATLAB® is not hard to learn if you go for any professional course. It is ideal for engineering graduates and IT professionals willing to develop MATLAB® skills in their related fields.

Is Simulink worth it? ›

Simulink is one of the most effective block diagram environment for modelling, simulation, and analysis of diverse systems. It is an intuitive tool that is very simple to understand.


Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 5549

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.