MATLAB: Ploting discrete singnal using heaviside

ploting discrete singnal using heaviside

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

Best Answer

That is the definition of the heaviside function.
From the documentation:
  • heaviside(x) returns the value 0 for x < 0, 1 for x > 0, and 1/2 for x = 0.