- heaviside(x) returns the value 0 for x < 0, 1 for x > 0, and 1/2 for x = 0.
ploting discrete singnal using heaviside
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
irtaza anwar
le 12 Avr 2015
Commenté : Star Strider
le 12 Avr 2015
n = -5 : 5;
y = heaviside(n); stem(n, y) axis([-5 5 -1 2])
i am writing this code but it gives 0.5 on 0 and for n>0 gives 1
0 commentaires
Réponse acceptée
Star Strider
le 12 Avr 2015
From the documentation:
2 commentaires
Star Strider
le 12 Avr 2015
I thought you just did that in the code you posted:
n = -5 : 5;
y = heaviside(n);
stem(n, y)
axis([-5 5 -1 2])
That produces the plot I would expect.
You can define the unit step function as:
x = [-5 : 5];
unit_step = @(x) (x >= 0);
figure(2)
stem(x, unit_step(x))
That is not the definition of the Heaviside function, but is an acceptable definition for the unit step function. Use the one that is most appropriate for your needs.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!