MATLAB: Is it correct? (dirac delta function)

stem

Hi. I want to stem this function,
and this is my code.
i wonder it is correct.

Best Answer

no it should be 2*(n==0)
However there is another sense in which dirac(x) should be infinite when x is 0 instead being 1.