How do I change the value of the HEAVISIDE function from NaN to 1/2 when in Symbolic Math Toolbox 3.2 (R2007a)?

4 views (last 30 days)
The HEAVISIDE function is desigedn to return NaN for x== 0. I would like the HEAVISIDE function to return 1/2 instead.
When I execute:
f=heaviside(sym('0'))
The ouput is:
f =
NaN
How can I modify the output of 'heaviside(sym('0'))' to 1/2 instead of NaN?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The value of heaviside(sym('0')) can be altered form NaN to any value (say 1/2). This can be achieved by modifying the status of 'heaviside()' in Maple, which is 'undefined' by default, in the Maple Kernel.
You can do this as follows:
At the MATLAB command prompt, type:
maple('At_zero_return_one_half := proc(f,X) if f = Heaviside and X[1] = 0 then NumericStatus(invalid_operation=false);1/2;else undefined;end if;end proc:');
maple('NumericEventHandler( invalid_operation = At_zero_return_one_half ): forget(Heaviside):');
This will assign the value 1/2 to heaviside(0) in the Maple kernel.
You can verify that you obtain the expected behavior:
f=heaviside(sym('0'))
returns:
f =
1/2
Once you have completed the task, if you desire to clear these settings on HEAVISIDE, please type:
maple restart
to restart Maple

More Answers (0)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!