Bug Plotting Heaviside Step Function

25 views (last 30 days)
Marceli Narcyz
Marceli Narcyz on 8 Sep 2011
I'd expect this:
fplot(@(t) (heaviside(t) - heaviside(t-1)), [-5 5]);
to show 1 between [0,1) and 0 elsewhere. Instead, I get a flat line of all zero. If I change the plot range:
fplot(@(t) (heaviside(t) - heaviside(t-1)), [-2 2]);
that creates the plot that I'd expect over that range.
Further exploration shows that this works:
fplot(@(t) (heaviside(t) - heaviside(t-1)), [-3 3.25]);
but this one does not:
fplot(@(t) (heaviside(t) - heaviside(t-1)), [-3 3.3]);
This looks like a bug in Matlab. Any ideas?

Answers (0)

Community Treasure Hunt

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

Start Hunting!