MATLAB: How to integrate a multivariable function that includes Dirac delta

dirac deltamultivariable integration

I'm trying to integrate an expression that includes a Dirac delta function, but the "integral" function (as well as integral2 and integral3) isn't handling the Dirac delta correctly.
For example,
f = @(x) dirac(x);
q = integral(f,-100,100)
gives me an incorrect answer of 0, while
p = int(dirac(x),x,-100,100)
gives me a correct answer of 1.
Is this just a factor of the integral function using numerical integration? If so, any recommendations for how to integrate multivariable functions with a Dirac delta in MATLAB?

Best Answer

When you use integral() you need to add Waypoints corresponding to everywhere the dirac changes between zero and non-zero, because each dirac is a discontinuity.