A common way to generate an approximation of a delta function in Matlab is to use the Kronecker Delta. The Kronecker Delta is a discrete function that equals one when the subscript is zero and zero otherwise. One implementation of a Kronecker Delta is using the unit impulse function impulse()
of the Signal Processing Toolbox. Here's an example:
main.m103 chars3 lines
This generates a 1x10 vector that contains a delta function at imp(1)
, and zeros otherwise. You can increase or decrease the length of the impulse response vector zeros(1,9)
to have a longer or shorter delta function.
Note, however, that the Kronecker Delta is only an approximation of the true delta function.
gistlibby LogSnag