Step Response in MATLAB

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 immediately be plotted. 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 command to use the step function is the following:

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 problems you will come across in the beginning will be SISO or Single-Input, Single-Output. In this case there will only be one plot made, but the step command handles these problems in the same manner as a SIMO or Single-Input, Multiple-Output.

For example, suppose you want to model a mechanical system consisting of a mass, spring, and damper, with an applied force. You have come up with 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 into MATLAB:

     M = 1;
     K = 10;
     B = 2;
     num = 1;
     den = [M B K];
     sys = tf(num,den);
     
     step(sys)
You should see the following figure:

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.1m (the spring force balances the applied force). The system is underdamped and has an overshoot.

That's about it for the basic use of the step command. If you are interested, or if you need to use a step command in a more complex format, continue reading.

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 fact 100N. The step command can accommodate this by multiplying the system by 100. For the example above, you should get the following plot

The plot looks similar to the one above it except that the scale on the y-axis is different.

Specifying the time scale

Both the step response for a set of state space equations or for a transfer function 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. The commands to use the time vector are 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 above m-file in MATLAB:
     t=0:0.1:10;
     step(sys,t)
you should get the following plot:

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 a left hand arguments. There are two ways to invoke the left hand arguments, depending on whether or not the time vector was used in the step command. If the time vector is used, the command is:
     [y,t] = step(sys);
	 
	 or
	 
     [y,t] = step(sys,t);
	 
If the system is in state-space form, all of the states can 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 left hand arguments, no plot is drawn for the step command. You will usually want to put a semicolon after the step command when you invoke it with left-hand 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) or the state response using plot(t,x).

Step response of discrete-time systems

If the system "sys" 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.


Use your browser's "Back" button to return to the previous page.