% EE3221 W6D1 Dr. Durant 1/2021 % Demonstration cancellation (z-domain and convolution) % of certain frequencies by an averaging filter. % z_cancellation clearvars close all % x(n) = sin(Wn) u(n) % X(z) = (z sin(W))/(z^2 - 2z cos(W) + 1) % Let W = 2pi/3 radians/sample % e^jW = -1/2 + j sqrt(3)/2 = cos(W) + j sin(W) % X(z) = (z sqrt(3)/2)/(z^2 + z + 1) % Check roots of denominator % Let h(n) = u(n) - u(n-3) % H(z) = z/(z-1) - z^-2/(z-1) = (z - z^-2)/(z-1) = (z^3-1)/((z^2)(z-1))) % check roots and cancel... H(z) = (z^2+z+1)/z^2 % Y(z)/z = H(z)X(z)/z = (sqrt(3)/2) / z^2 % Y(z) = (sqrt(3)/2) / z % y(n) = (sqrt(3)/2) delta(n-1) W = 2*pi/3; n = 0:20; x = sin(W*n); h = zeros(size(x)); h(1:3) = 1; y = conv(x,h); plot(n,y(1:length(n)),'b*', n,x,'r+', n,h,'g^') legend('y', 'x', 'h')