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

2 replies · 8K views · last reply
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.
 
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))
 
If it's required you write it yourself, you're going to have to give us your code if you want troubleshooting help.