
What is heaviside and how replace ?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
COTTINEAU Christophe
le 8 Oct 2015
Réponse apportée : COTTINEAU Christophe
le 8 Oct 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
0 commentaires
Réponse acceptée
Stephen23
le 8 Oct 2015
Modifié(e) : Stephen23
le 8 Oct 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:

0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!