% ===============================================
% ECE2311 D10
% Sifting property demonstration
% DRB 23-Mar-2010
% ===============================================

format compact
clc

syms t real                         % declare t as a symbolic variable
f0 = 100;                           % frequency
phi0 = pi/10;                       % phase
tau = 0.5;                          % delay
epsilon = 0.1;                      % epsilon parameter in DELTA(t)
f = cos(2*pi*f0*t+phi0);            % symbolic expression for function inside integral
ftau = cos(2*pi*f0*tau+phi0);       % function evaluated at t=tau

while epsilon>=1e-6,
    integral = eval(int(f*(1/epsilon),t,tau-epsilon/2,tau+epsilon/2));
    disp(sprintf('epsilon = %f: f(tau) = %f and integral = %f.',epsilon,ftau,integral))
    epsilon = epsilon/10;
end

