
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:
step(sys)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.
step(100*sys);

The plot looks similar to the one above it except that the scale on the y-axis is different.
step(sys,t)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.
[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).
num = 1; den = [1 0.5]; sys = tf(num,den,-1) step(sys)

If the sampling time is specified, the time scale will be in seconds.
num = 1; den = [1 0.5]; Ts = 0.1; sys = tf(num,den,Ts) step(sys)
