EDUCBA

EDUCBA

MENUMENU
  • Explore
    • Lifetime Membership
    • All in One Bundles
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Login
Home Data Science Data Science Tutorials Matlab Tutorial Step Function Matlab

Step Function Matlab

Updated June 7, 2023

Step Function Matlab

Introduction to Step Function Matlab

The step function in Matlab is used for design control. We used to step and unit steps for immediate plotting of scalar input without using any particular toolbox in Matlab. A discontinuous function has zero value for a negative argument and has one value for a positive argument called a unit step function. We can apply the step function along with any other function, also called a system function. Once the system function is defined, then we can pass this function through the step function.

ADVERTISEMENT
Popular Course in this category
MATLAB Course Bundle - 5 Courses in 1 | 3 Mock Tests

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Syntax:

The syntax for Step Function Matlab is as shown below:

Step (sys)

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.

The 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 a zeroth row vector to avoid garbage value.

Step 5: Write the unit step command.

Step 6: Finally, plot the function.

We also plot a transfer function response by using a step function.

The steps are as follows:

Step 1: Take a numerator in a variable.

Step 2: Take the denominator in another variable.

Step 3: Generate the transfer function using the ‘tf’ function and assign it to the sys1 variable.

Step 4: Use the step function to plot a response.

Examples of Step Function Matlab

Given below are the examples :

Example #1

In this example, we learn how to use the step response functionality in matlab to plot the step response of 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 understands, and we do that by writing down the vectors that represent the numerator and numerator. So we take two variables to represent the numerator and denominator, and these variables are num1 and den1, respectively. So, the numerator here is a num1 = [ 1 1 ], first 1 corresponds to s, and 2nd 1 corresponds to constant. The denominator here is den1 = [ 1 1 2 1 ], 1st one corresponds to s cube, 2nd one corresponds to s square, 2 corresponds to s, and the last 1 corresponds to the constant. Then we take sys1 equals to TF is a standard function for generating 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 the sys1 variable. Now we use a step function to plot the step response of a system. Then we also use a grid function to look at grids on a plot.

Code:

clc;
close all;
clear all;
num1 = [ 1 1 ];den1 = [ 1 1 2 1 ];sys1 = tf (num1, den1)step(sys1)grid on

Output:

step function matlab 1

Example #2

Let us see an example; we plot a 2nd order state–space model in this example. We take 4 variables, a1, b1, c1, and d1 which 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 the 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 assigns to sys1. And then, we plot the response using a step function; it shows two responses.

Code:

clc;
close all;
clear all;
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

Output:

we plot a 2nd order state – space model

The left plot shows the step response of the first input channel, while the right plot displays the step response of the second input channel.

Example #3

Let us see an example for generating a delayed or advanced unit step signal; 1st, we ask a user to enter an interval for which you want to get a step signal; for taking user values, we use an input function, which requests the user input and that number into which user entered that stored in an equitant variable. We also ask the user to close that the signal is delayed (+ve no.) or advanced (-ve no.). Then, in the x1 variable, we define a time axis. Then, to avoid trash values, we generate the zeroth row vector, which equals the unit step_CT variable. Then, we utilize a plot function to draw a unit step based on whether it is delayed or advanced. Then, using the xlabel and ylabel functions, we label the figure as the x-axis is time and the y-axis is amplitude. And using the title function, we give a title to that response. And we also use a grid function to display the grid on the plot.

Code:

clc;
close all;
clear all;
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;
plot(x1,unitstep_CT,'b','linewidth',2);
xlabel('Time');
ylabel('Amplitude values');
title('CT unit step signal');
grid on

Output:

step function matlab 4

Conclusion

In this article, we saw the concept of the Step function in Matlab. People use the step function for control design. I then observed the syntax related to the step function and learned how to use it in Matlab code. Also, we saw some examples related to the Step function and its output on matlab.

Recommended Articles

We hope that this EDUCBA information on “Step Function Matlab” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. String Array in Matlab
  2. Trapezoidal Rule Matlab
  3. Matlab trapz()
  4. MATLAB Derivative
ADVERTISEMENT
SPSS Course Bundle - 14 Courses in 1 | 5 Mock Tests
34+ Hours of HD Videos
14 Courses
5 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
MICROSOFT AZURE Course Bundle - 15 Courses in 1 | 12 Mock Tests
63+ Hour of HD Videos
15 Courses
12 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
HADOOP Course Bundle - 32 Courses in 1 | 4 Mock Tests
125+ Hour of HD Videos
32 Courses
4 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
ADVERTISEMENT
INFORMATICA Course Bundle - 7 Courses in 1
47+ Hours of HD Videos
7 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Extended Cyber Monday Price Drop! All in One Universal Bundle (3700+ Courses) @ 🎁 90% OFF - Ends in ENROLL NOW