What is the syntax for defining a Heaviside function in MATLAB?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 8K views
adnan jahan
Messages
93
Reaction score
0
Dear Fellows
I need to define a function "f" in MATLAB as
f is a heaviside unit step function

I did it as

f = heaviside[abs(-4)]

but it is not working as I required.
 
Physics news on Phys.org
adnan jahan said:
Dear Fellows
I need to define a function "f" in MATLAB as
f is a heaviside unit step function

I did it as

f = heaviside[abs(-4)]

but it is not working as I required.
The "heaviside" function is part of the symbolic maths toolbox and as such, requires a symbolic argument. Therefore, you need to modify your expression thus:
Code:
heaviside(sym(abs(-4))