|
|
The step function is one of most useful functions in Matlab for control design. Given a system that can be described by either a transfer function or a set of state-space equations, 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 one of the following (depending if you have a set of state-space equations or a transfer function form):
step(A,B,C,D)
step(num,den)
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, rigid body system, and you have come up
with the state equations with the matrices shown below. The
two states are the position and the velocity. You wish to see what the
system response to unit step disturbance is. The unit step disturbance
will be a change of the force acting on the system from zero Newtons
one Newton at time t= 0. To model this, enter the
following into Matlab:
A = [0 1
0 -.05];
B= [0
0.001];
C = [1 0
0 1];
D = [0
0];
step(A,B,C,D)
This set of state equations has one input (force acting on the system) and
two different outputs (position and velocity), so the figure given by the
step command will have two plots. One plot will be for each
output. You should see the following figure:
This figure contains two plots, one for the position and one for the velocity. If there was only one output (i.e. the C matrix had only one row), then the figure would only contain one plot. The bottom plot shows the velocity response. The velocity exponentially increases from zero to some finite velocity (0.02 m/s). The first plot shows the position response. The system's position is parabolic until a constant velocity is achieved, at which point the position increases linearly with time.
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.
The step command can also be used for a system with more than one input as follows:
step(A,B,C,D,iu)
In this form, the step command will make one figure with all of
the outputs plotted with a step on the iu'th input. For example, in the m-file
given above, if the first (and in this case, only) input was specified,
both of the plots shown before would now be plotted on the same set of
axes. It is hard to see because of the scaling, but if the step
command was changed to the following two lines:
step(A,B,C,D,1)
axis([0 100 0 0.1])
You will get the figure shown below. The position (shown in blue) and
the velocity (shown in green) are both plotted on the same axis. The axis was changed so the velocity response
could be seen along with the position.
Again, if only one output would have been specified in the C matrix, the figure would only have one curve.
If you are given the transfer function to the system instead of the state-space equations, the step command is used as step(num,den). Because a transfer function can only have one input, all of the outputs (represented by the number of rows in the numerator of the transfer function) will be plotted on one set of axes. If you want to verify this for yourself, change the above state-space equations to a transfer function and then plot the step response:
The plot looks similar to the two above it except that the scale on the y-axis is different. The velocity plot now rises to 2 instead 0.02.
A = [0 1
0 -.05];
B= [0
0.001];
C = [1 0
0 1];
D = [0
0];
[num,den]=ss2tf(A,B,C,D)
t=0:0.1:80;
step(num,den,t)
axis([0 100 0 0.1])
you should get the following plot:
As you can see, the plot cuts off at 80 seconds. The axis command was designed to extend past the cut off, so it could be seen. Note that this is not usually done in plotting, as it makes it seem like the response just ends at 80 seconds.
[y,x] = step(A,B,C,D,iu,t); or
[y,x] = step(num,den,t);
If the time vector is not used, the command is:
[y,x,t] = step(A,B,C,D,iu); or
[y,x,t] = step(num,den);
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 state response
using plot(t,x).
8/29/96 JDP