What is the problem with the heaviside function?

 Respuesta aceptada

Star Strider
Star Strider el 10 de Sept. de 2015
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.

2 comentarios

Mr M.
Mr M. el 10 de Sept. de 2015
Symbolic Math Toolbox for what? for the heaviside function??
Star Strider
Star Strider el 10 de Sept. de 2015
Editada: Star Strider el 10 de Sept. de 2015
Yes. The heaviside function is only in the Symbolic Math Toolbox. My function provides the same results, so you can use it instead. I abbreviated its name to ‘hvsd’ be sure it didn’t overshadow heaviside on my computer so I could test both of them. You can obviously name it whatever you want.

Iniciar sesión para comentar.

Más respuestas (1)

Thorsten
Thorsten el 10 de Sept. de 2015
Editada: Thorsten el 10 de Sept. de 2015
The error means that Matlab cannot find the heaviside function. Try
which heaviside
to locate the function. The heaviside function is part of the Symbolic Math Toolbox. If you do not have this TB, you can write your own heaviside function
function y = heaviside(x)
y = (x > 0) + 0.5*(x == 0);

1 comentario

Dief Gerard
Dief Gerard el 10 de Feb. de 2022
@Thorsten Thanks for your answer. It helped me debug my code.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 10 de Sept. de 2015

Comentada:

el 10 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by