What is heaviside and how replace ?

5 visualizaciones (últimos 30 días)
COTTINEAU Christophe
COTTINEAU Christophe el 8 de Oct. de 2015
Respondida: COTTINEAU Christophe el 8 de Oct. de 2015
Hello,
I try to used a example plot.m find on Internet :
%%COURBE AVEC UN CRENEAU
figure
t=-20:20;
y = heaviside(t)
plot(t,y)
axis([-10 10 -2 2])
but the my Matlab R2015a say :
Undefined function or variable 'heaviside'. Error in Plot (line 130) y = heaviside(t)
and help don't find also
Please help Best regards Christophe

Respuesta aceptada

Stephen23
Stephen23 el 8 de Oct. de 2015
Editada: Stephen23 el 8 de Oct. de 2015
When you do a search of the documentation like this:
the green text underneath each search result tells you what toolbox or product that result applies to. The results of searching for "Heaviside" produces only results for the "Symbolic Math Toolbox", ergo heaviside is not a standard MATLAB function.
If you want a numeric version to use in MATLAB then try this anonymous function:
myHeaviside = @(V)(1+sign(V))/2;
which uses the H(0)==0.5 convention. Here it is used with your code:
>> myHeaviside = @(V)(1+sign(V))/2;
>> t = -20:20;
>> y = myHeaviside(t);
>> plot(t,y)
>> ylim([-0.1,1.1])
which produces this figure:

Más respuestas (1)

COTTINEAU Christophe
COTTINEAU Christophe el 8 de Oct. de 2015
Excellent Thanks

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by