MATLAB: What does Error using heaviside (line 36) mean in MATLAB

error line 36heavisideMATLABsymbolicSymbolic Math Toolbox

Hi. I tried doing this to my installed 2020a MATLAB but I get an error:
>> t =@(x) (heaviside(x+1)-heaviside(x-1)).*(1-abs(x));
>> t(-1)
Error using heaviside (line 36) Function call 'heaviside(0)' yields a symbolic object. Use 'sympref("HeavisideAtOrigin", v)' with some numeric value v to change 'heaviside(0)' to v.
Error in @(x)(heaviside(x+1)-heaviside(x-1)).*(1-abs(x))
I tried in the online version of 2020a and it worked. Why is it not working in my computer?
I checked if I have Symbolic Math Toolbox, and I have the same version as that in the online version. v 8.5

Best Answer

To duplicate this, you would need to have done something like
syms x
sympref('heavisideAtOrigin', x); %set the preference to something not convertable to numeric
clear heaviside %clear AFTER having set sympref
heaviside(0) %and you get the error
To get rid of the problem, you can
sympref('heavisideAtOrigin', 'default')