Symbolic Discrete Delta Function

by

 

Discrete delta function for symbolic operations

symIndicator(o1, o2, varargin)
function ind = symIndicator(o1, o2, varargin)
    % (Crappy) discrete time indicator function:
    % Constructed using the difference between two heaviside functions with
    % the hope that user will always evaluate the function at integers
    % 
    % if invert==1, return I(o1~=o2)
    % else, return I(o1==o2)
    %
    if ~isempty(varargin) 
        invert = varargin{1}; 
    else 
        invert = 0; 
    end
    
    ind = 2*(heaviside(o1-o2)-heaviside(o1-o2-0.0001)) ;
    
    if invert, ind = 1-ind;  end
end

Contact us