Why doesn't heaviside start and end according to the array passed to it?

2 views (last 30 days)
The stem plot that results from
stem(heaviside(-100:100))
starts at 100 and ends at 200. Why doesnt it start at -100 and end at 100 like the array? Also, why is the amplitude of the stem at 100 only 0.5?

Answers (1)

Walter Roberson
Walter Roberson on 8 May 2015
Edited: Walter Roberson on 8 May 2015
If Y is a vector, then the x-axis scale ranges from 1 to length(Y).
What you probably want is:
Y = -100:100;
stem(Y, heaviside(Y));
heaviside(x) returns the value 0 for x < 0, 1 for x > 0, and 1/2 for x = 0.
The 101'st entry was the one for which the data value was 0.

Categories

Find more on Denoising and Compression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!