Introduction to Step Function Matlab
Step function in Matlab is used for design controlling. We used step and unit step for immediate plotting of scalar input without using any special toolbox in Matlab. A discontinuous function has zero value for negative argument and have one value for positive argument called a unit step function. We can apply step function along with any other function which is also called as a system function. Once system function is defined then we can pass this function through step function.
The syntax for Step Function Matlab is as shown below:
How to do Step Function Matlab?
Here we will see how to write a matlab code for generating an advanced or delayed unit step function.
Steps are as follows:
Step 1: Take interval from user or decide by programmer.
Step 2: Take user or programmer choice either advanced or delayed function.
Step 3: Define time axis.
Step 4: Create zero’ th row vector to avoid from garbage value.
Step 5: Write unit step command.
Step 6: Finally plot the function.
We also plot a transfer function response by using a step function.
Steps are as follows:
Step 1: Take a numerator in a variable.
Step 2: Take denominator in another variable.
Step 3: Generate transfer function using ‘tf’ function and assign to sys1 variable.
Step 4: Use step function to plot a response.
Examples of Step Function Matlab
Given below are the examples :
In this example we learn how to use the step response functionality in matlab to plot the step response the transfer function, we have G1 of s equals to s plus 1 divide by s cube plus s square plus 2s plus 1. Now we need to input this step function in a format that matlab understand and the way we do that is by writing down the vectors that represents numerator and numerator. So we take two variables to represent the numerator and denominator and these variables are num1 and den1 respectively. So, numerator here is a num1 = [ 1 1 ], first 1 is correspond to s and 2nd 1 correspond to constant and denominator here is den1 = [ 1 1 2 1 ] , 1st one is correspond to s cube, 2nd one correspond to s square, 2 is correspond to s and last 1 is correspond to constant. Then we take sys1 equals to TF is a standard function for generates a transfer function in the s domain, s domain is a laplace domain given numerator (num1) and denominator (den1) there we have a transfer function in sys1 variable. Now we use a step function to plot step response of a system. Then we also use a grid function to look grids on a plot.
num1 = [ 1 1 ];den1 = [ 1 1 2 1 ];sys1 = tf (num1, den1)step(sys1)grid on
Let us see an example, in this example we plot a 2nd order state – space model. We take a 4 variables a1, b1, c1 and d1 this are Nx-by-Nx real- or complex-valued matrix. In our example the value of d1 is zero. And these 4 variables are passed from ss function, ss is a state space model. sys1 = ss (a1,b1,c1,d1) creates the discrete-time state-space model object of the following form: x[n+1]=a1x[n]+b1u[n] and y[n]=c1x[n]+d1u[n]. And this assign to sys1. And then we plot the response using a step function it shows a two responses.
a1 = [-0.55, -0.78; 0.78,0];b1 = [1,-1;0,2];c1 = [1.96, 6.44];d1 = 0;sys1 = ss(a1, b1, c1, d1);step(sys1)grid on
The step response of the first input channel is shown in left plot, and the step response of the second input channel is shows in right plot.
Let us see an example for generating a delayed or advanced unit step signal, 1st we ask a user to enter a interval for which you want to get step signal, for taking a user values we use a input function, it request the user input and that number into which user entered that stored in equitant variable, then we also ask the user to close that the signal is delayed (+ve no.) or advanced (-ve no.). Then we define a time axis in x1 variable. Then we create zero’th row vector to avoid from garbage value and this equal to unit step_CT variable. Then we use a plot function to plot a unit step according to delayed or advanced. Then we label the figure as x axes is time and the y- axes is amplitude using xlabel and ylabel function. And using title function we give a title to that response. And we also use a grid function to display the grid on plot.
n = input('Enter the interval for which you want to get unit step signal: - ');
d = input ('Enter the delayed (+ve no. ) or advanced ( -ve no. ):- ');
x1 = -5:0.01:5;
unitstep_CT = zeros(size(x1));
unitstep_CT(x1>=0 + (d)) = 1;
title('CT unit step signal');
In this article, we saw the concept of Step function in matlab. Basically Step function is used for control design. Then saw syntax related to Step function and how it is used in matlab code. Also, we saw some examples related to the Step function and its output on matlab.
This is a guide to Step Function Matlab. Here we discuss the introduction, how to do step function matlab, and examples respectively. You may also have a look at the following articles to learn more –