To plot a step response of a discrete system, we will use two separate Matlab functions, dstep and stairs. The dstep will be used to obtain N number of output sample points, where N is supplied by an user. The stairs plots a stairstep graph of supplied vectors, namely the time vector [t] and the amplitude vector [x].
We will use the dstep to obtain a vector of sample points. Create an m-file and enter the following commands.
Notice that the function dstep does not consider the time vector [t]; instead, it considers the number of sample points (N). In deed, if you take out the left hand side argument [x] from the dstep(numDz,denDz) command, you get the step response of the system as a function of sample (k), not as a function of time (Try this yourself).
To obtain a response as a function of time, first, we need to consider the relationship between the number of samples and the sampling time (Ts). Let's say our digital control system has the sampling time of t sec/sample. Using this digital control system, it takes t*(N-1) seconds to obtain N samples. For example, if above 101 samples were taken with the system having a sampling time of 0.05 sec/sample, the total sampling period equals to 5 seconds. If you plot this, it looks like the following.
The function stairs connects these sample points in a way that it represents the output y(k) preceded by zero-order hold. Let's use stairs to connect these sample points. Add the following commands to the above m-file and rerun it. You should get the following stairstep response.
The following commands will plot a stairstep response of the system represented by this state-space model. Copy these commands to an new m-file and run it.
You should see the same plot as the one shown above.