clear all; close all; warning('off','MATLAB:dispatcher:InexactMatch') % 4th Homework 'DFT Examples' % (a). Find & draw |X(omega)|, |H(omega)|, |Y(omega)| x = [ 1, 2, 2, 1]; h = [ 1, 2, 3]; y = conv (x, h); magX1 = abs(hw4(x, length(x), 1)); magH1 = abs(hw4(h, length(h), 1)); magY1 = abs(hw4(y, length(y), 1)); figure('name', '(a) - |X(§Ù)|, |H(§Ù)|, |Y(§Ù)| & (b) - |X(k)|, |H(k)|, |Y(k)|', 'Position', [50, 50, 600, 600], 'MenuBar', 'none') subplot(3,2,1); plot(magY1, 'DisplayName', 'magY1', 'YDataSource', 'magY1'); title('Response Y(§Ù)'); grid on; hold all; subplot(3,2,3); plot(magX1, 'DisplayName', 'magX1', 'YDataSource', 'magX1'); title('Response X(§Ù)'); grid on; subplot(3,2,5); plot(magH1, 'DisplayName', 'magH1', 'YDataSource', 'magH1'); title('Response H(§Ù)'); grid on; % (b) Find & draw |X(k)|, |H(k)|, |Y(k)| x = [x, zeros(1,4)]; h = [h, zeros(1,5)]; y = [y, zeros(1,2)]; magX2 = abs(hw4(x, length(x), 2)); magH2 = abs(hw4(h, length(h), 2)); magY2 = abs(hw4(y, length(y), 2)); subplot(3,2,2); plot(magY2, 'DisplayName', 'magY2', 'YDataSource', 'magY2'); hold; grid on; axis([1 10 0 40]); subplot(3,2,2); stem(magY2, 'DisplayName', 'magY2', 'YDataSource', 'magY2'); title('Response Y(x)'); subplot(3,2,4); plot(magX2, 'DisplayName', 'magX2', 'YDataSource', 'magX2'); hold; grid on; axis([1 10 0 6]); subplot(3,2,4); stem(magX2, 'DisplayName', 'magX2', 'YDataSource', 'magX2'); title('Response X(x)'); subplot(3,2,6); plot(magH2, 'DisplayName', 'magH2', 'YDataSource', 'magH2'); hold; grid on; axis([1 10 0 6]); subplot(3,2,6); stem(magH2, 'DisplayName', 'magH2', 'YDataSource', 'magH2'); title('Response H(x)'); hold off; figure(gcf)