generate a delta function without syms or the dirac function in matlab

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.m
% Generate a delta function using a unit impulse
imp = impulse([1 zeros(1,9)]) % 1x10 impulse response
103 chars
3 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.

related categories

gistlibby LogSnag