Why is 0 and 30 1/2?
4 views (last 30 days)
Alexander Bearon on 6 May 2022
Trying to plot the function x[n] = u[n] - u[n-30]. I'm getting 1/2 for n=0 and n=30. The correct answer is 1 from 0-29 and 0>=30, right? Below is my code and the result. I've tried heaviside(sym(n)) - heaviside(sym(n-30)) and I get the same result (I don't really know the differnce between using sym and not).
Walter Roberson on 6 May 2022
heaviside(X) by default has a value of 1/2 when X has a value of 0
The Heaviside function does not have a well-defined value at 0 exactly. There are at least three different values for Heaviside(0) that are useful in practice: 0, 1, and 1/2 . When you reach 30, then has the value "not yet jumped", or has it "already jumped", or is in "in the process of jumping" ? Is the glass half-full or is it half-empty ?
You can use sympref('HeavisideAtOrigin') to change the value that heaviside(0) will return.