EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • All Courses
    • All Specializations
  • Blog
  • Enterprise
  • Free Courses
  • All Courses
  • All Specializations
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Heaviside MATLAB
 

Heaviside MATLAB

Priya Pedamkar
Article byPriya Pedamkar

Updated February 27, 2023

Heaviside MATLAB

 

 

Introduction to Heaviside MATLAB

The following article provides an outline for Heaviside MATLAB. Heaviside function is used in Mathematics for problems involving signal processing and control theory to project signals that switch ON at specified times & stay ON indefinitely. Heaviside function represented as H (x) is discontinuous function with its value as zero if the argument is negative and 1 in case the argument is positive. The function is also referred as unit step function.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax of Heaviside function in MATLAB:

Heaviside (x)

Heaviside (x) will evaluate Heaviside step at the argument value ‘x’.

Examples of Heaviside MATLAB

Given below are the examples mentioned:

Example #1

Here we will compute Heaviside function of a symbolic value using Heaviside (x).

Let’s take a negative value for our first example; i.e -4. As per the definition of Heaviside function, we should get ‘0’ as output for a negative value.

Syntax:

Hs = heaviside (sym (-4)) [passing the negative argument to the Heaviside function]

Code:

Hs = heaviside (sym (-4))

Output:

Heaviside MATLAB 1

As we can see, the output of the Heaviside function is ‘0’ for the negative input, as expected by us.

Example #2

Here is an example where we compute Heaviside function for a positive argument using Heaviside (x).

Let’s take ‘5’ as our input argument. As per the definition of Heaviside function, we should get ‘1’ as output for a positive argument.

Syntax:

Hs = heaviside (sym (5)) [passing the positive argument to the Heaviside function]

Code:

Hs = heaviside (sym (5))

Output:

for a positive argument

As we can see, the output of the Heaviside function is ‘1’ for the positive input, as expected by us.

Example #3

Here we will compute Heaviside function for a range of values using heaviside (x) and will plot them to see the output.

Let’s take a range of numbers from 0 to 5 as our input argument. As per the definition of Heaviside function, we should get ‘1’ as output for all these values. So, Mathematically, our output will be a straight line parallel to x-axis at y = 1.

Syntax:

syms x [Initializing the variable] fplot (heaviside (x), [0, 5]) [passing the input range as argument and plotting the output]

Code:

syms x
fplot (heaviside (x), [0, 5])

Output:

Heaviside MATLAB 3

As we can see, the output of the Heaviside function is ‘1’ for the positive range of values, as expected by us.

Example #4

Here we will compute Heaviside function for a range covering both positive and negative values using heaviside (x) and will plot them to see the output.

Let’s take a range of numbers from -5 to 5 as our input argument. As per the definition of Heaviside function, we should get ‘1’ as output for all the positive values and ‘0’ for all the negative values. So, Mathematically, our output will be 2 straight lines, one parallel to x-axis at y = 1 and the other one along the x-axis; i.e at y = 0.

Syntax:

syms x [Initializing the variables] fplot (heaviside (x), [-5, 5]) [passing the input range as argument and plotting the output]

Code:

syms x
fplot (heaviside (x), [-5, 5])

Output:

range covering both positive and negative values

As we can see, the output of the Heaviside function is ‘1’ for the positive range of values and ‘0’ for the negative range of values, as expected by us.

Recommended Articles

This is a guide to Heaviside MATLAB. Here we discuss the introduction to Heaviside MATLAB along with examples to calculate the unit step. We can calculate the Heaviside function for both positive and negative values. You may also have a look at the following articles to learn more –

  1. Break in MATLAB
  2. Size Function in MATLAB
  3. fminsearch in Matlab
  4. Matlab Errorbar
Primary Sidebar
Footer
Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - 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
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

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

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 Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW