leftimage for poohprod.ru

Heaviside Unit Step Function

The unit step function (also known as the Heaviside function) is a discontinuous function whose value is zero for negative arguments and one for positive arguments. The Heaviside function is the integral of the Dirac delta function.


This concept can be mathematically expressed as:

Definition of the step function - Heaviside unit step

Our current intention is not to deal with all the formal details. In this brief article we're going to deal with it in an informal way, in order to just operate with it and create some plots in Matlab.

This function is commonly utilized in control theory or digital signal processing (dsp) to represent a signal that switches on at a specified time and remains switched on indefinitely.

The function depends on real input parameters. We can define the function having a scalar number as an input. For example, let’s create a discrete plot without using any special toolbox in Matlab.

function y = step_fun(n)
% We assume a scalar input
% Our default output value is 0

y = 0;

% We change our output to 1 if the argument is greater
% than or equal to 0

if n >= 0
y = 1;

end


If we want to get a plot from there, we have to iterate utilizing real numbers. If the input is an integer, then the function will be a discrete one. To stress the fact that we're working with discrete functions here, we'll use 'stem' instead of 'plot'.


Let's call the function from another script. For example:

% We iterate from -5 to 5 using only integers
for n = -5 : 5
y = step_fun(n);
stem(n, y)
hold
on
end
% We adjust our axis values just to visualize better
axis([-5 5 -1 2])

and we get

unit step function: result from a discrete iteration

Now, let’s say that we have a vector (not a scalar) as an input. We want to calculate the Heaviside function for all of the values included in the vector. We can create another function to considerate this approach:

function y = heaviside(n)
% We assume a vector input

% Our default output value is 0
y = 0 * n;
% Now, we find values in n greater than or equal to 0
y(find(n >= 0)) = 1;


We don’t need a loop now, so our process has been simplified a lot. Let's use this new approach.

n = -5 : 5;
y = heaviside(n);
stem(n, y)
axis([-5 5 -1 2])


The result is again:

vector output for the Heaviside function

If we want to calculate y = 4H(n) + 3H(n-2), in a range of integers that go from -10 to 10, we can do simply this:

n = -10 : 10;
y = 4 * heaviside(n) + 3*heaviside(n-2);
stem(n, y)
axis([-15 15 -1 8])

and the result is:

arithmetic operations on the Heaviside unit step function

We can see that every integer in the domain of the function counts to add to the final result, and that happens when the argument is zero for each term. The first term, 4H(n), adds a height of 4 (coefficient) at n = 0; the second term, 3H(n-2), adds a magnitude of 3 at n = 2.


From 'Step Function' to home

From 'Step Function' to 2D-plots Menu



Top

Periodic Functions

Impulse Function




footer for step function page











Related pages


cramers lawhow to write a piecewise function from a graphmatrix laboratorycapacitor power factor correction calculationmaclaurin series of cosxinterest calculator spreadsheetstatistics combination calculatorsurface plot in matlabconvert decimal to binary codematlab logical operatorstower of hanoi algorithmpermutation and combination calculatorfzero function matlabboxplot in matlabexponential growth or decay calculatorsolve matrix equation matlabfactorial equation calculatormatlab matrix inversionfind roots of quadratic equation calculatormatrix exponential calculator onlinematlab polynomial fitsimultaneous equations solver with workingsmatlab gaussian eliminationde morgans lawfuture value annuityascii chart generatorroot finding in matlabrate of decay calculatornon linear regression in matlabc code for pascal trianglenodal voltage analysishexa decimal systemmatlab normal distribution plotmatlab plot boxplot sine wave matlabalgorithm of bisection methodeir interestsketch piecewise functiondecimal ascii chartcombinational gateshistogram in matlabcalculating depreciation with salvage valuequadratic equation solver calculatorlogarithmic regression calculator onlinelogic for fibonacci seriescos matlabmatlab lookup tablematlab guide tutorialgraph of a piecewise functionmatlab trapezoidal methodnormal distribution bell curve generatorcartesian to polar converterelectricity cost calculator kwhamoritzation tablebinary to octal conversion methoddecimal to octal conversion formulawhat is impulse functionhow to calculate sq feet from inchespascal triangle codetrapezoidal rule code matlabfor and while loops matlabapplications of smith chartinverse of a matrix in matlabmatlab function scriptrc circuit simulationconvert ascii code to charactersolve definite integral calculatornormal probability plot matlabcombinational cktstepwise matlabmatlab least square fit