MATLAB: What is the problem with the heaviside function

functionheaviside

fun =
@(p,x)p(1)*heaviside(x-p(2))
Undefined function 'heaviside' for input arguments of type 'double'.

Best Answer

Your function works for me. Do you have the Symbolic Math Toolbox?
If you don’t substitute a call to this one for the heaviside call:
hvsd = @(x) [0.5*(x == 0) + (x > 0)];
I tested both, they give equivalent results.