Usage of heaviside command valid/legal for discrete time ?

5 views (last 30 days)
I have been using heaviside function for continuous time signals and system but now i want to use this command in discrete time signals & systems but i read in a book(Signals and Systems Laboratory with MATLAB,pg 102) that this command cannot be used for discrete time
I have tried heaviside command and it gives expected true result but i am not sure whether its use is legal in programming terms
clc
clear all
close all
n=0:5
x=heaviside(n)
stem(n,x)
Both expected and actual results are same but i am not sure whether its use is legal or not?

Accepted Answer

Walter Roberson
Walter Roberson on 18 May 2019
heaviside() is part of the Symbolic Toolbox. It is implemented by two different functions, one of which is used when the input is symbolic and the other when the input is not symbolic. When the input is symbolic, the symbolic engine is called. When the input is not symbolic, it effectively use Y(X > 0) = 1 and then does fixing up to account for sympref HeavisideAtOrigin, which was functionality added in your release.
Heaviside might possibly in some theoretical sense not be a function, especially since the value at 0 is not completely defined, but it is so close to being a function that it makes sense to generalize it to handle numeric input.
Heaviside is intended to represent something that turns on and stays on, which is in a way incompatible with the idea of discrete time because discrete time says that anything in-between the defined points is unknowable. But it is too useful to refuse to define Heaviside at specific numeric values.
  6 Comments
ABTJ
ABTJ on 19 May 2019
By "legal" i mean that MATLAB language and Compiler allows its use
As example the case you might have seen with C++ programing in relevant compilers forexample Turbo C++
Walter Roberson
Walter Roberson on 19 May 2019
Pure MATLAB without toolboxes does not permit heaviside() to be used at all, as heaviside is part of the Symbolic Toolbox.
In the Symbolic Toolbox, Mathworks deliberately implemented heaviside for numeric data types. Numeric examples are given as far back as I looked in the documentation (I looked back to R2006a.) The fact that it ran for you is no accident: Mathworks specifically choose to enable it.
What your book is talking about is whether using Heaviside on discrete time can be justified in theoretical terms, which is a different matter than whether Mathworks permits the operation.
The theory question is much like the question of the square root of 2 is a valid operation or not, since it cannot be expressed in any discrete system based upon rational numbers.
You mention MATLAB Compiler. MATLAB Compiler has no support for anything in the Symbolic Toolbox, not even for the routines that have easy numeric translations.

Sign in to comment.

More Answers (0)

Products


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!