ECE 34- LAB 4.0 Code: function linear_convol(x, h) y = convol(x, h); L = 0:(length(x)-1); M = 0:(length(h)-1); N = 0:(length(y)-1); printf('\nResult of linear convolution:\n'); disp(y); // Plot x[n], h[n], and y[n] clf; subplot(3, 1, 1); title('Input Signal x[n]'); xlabel('n'); ylabel('x[n]'); plot(L, x, 'b-', 'linewidth', 2, 'Marker', 'o'); plot([L; L], [zeros(1, length(x)); x], 'b--'); plot([0, length(y)-1], [0, 0], 'k-'); subplot(3, 1, 2); plot(M, h, 'r-', 'linewidth', 2, 'Marker', 'o'); plot([M; M], [zeros(1, length(h)); h], 'r--'); plot([0, length(y)-1], [0, 0], 'k-'); title('System Function h[n]'); xlabel('n'); ylabel('h[n]'); subplot(3, 1, 3); plot(N, y, 'g-', 'linewidth', 2, 'Marker', 'o'); plot([N; N], [zeros(1, length(y)); y], 'g--'); plot([0, length(y)-1], [0, 0], 'k-'); title('Linear Convolution x[n]*h[n]'); xlabel('n'); ylabel('y[n]');endfunction Figure (a) LAB 4.0 Figure (b) LAB 4.0 Figure (c) LAB 4.0 ECE 34- LAB 4.1 Code: function linear_convol(x, h) y = convol(x, h); L = 0:(length(x)-1); M = 0:(length(h)-1); N = 0:(length(y)-1); printf('\nResult of linear convolution:\n'); disp(y); // Plot x[n], h[n], and y[n] clf; subplot(3, 1, 1); title('Input Signal x[n]'); xlabel('n'); ylabel('x[n]'); plot(L, x, 'b-', 'linewidth', 2, 'Marker', 'o'); plot([L; L], [zeros(1, length(x)); x], 'b--'); plot([0, length(y)-1], [0, 0], 'k-'); subplot(3, 1, 2); plot(M, h, 'r-', 'linewidth', 2, 'Marker', 'o'); plot([M; M], [zeros(1, length(h)); h], 'r--'); plot([0, length(y)-1], [0, 0], 'k-'); title('System Function h[n]'); xlabel('n'); ylabel('h[n]'); subplot(3, 1, 3); plot(N, y, 'g-', 'linewidth', 2, 'Marker', 'o'); plot([N; N], [zeros(1, length(y)); y], 'g--'); plot([0, length(y)-1], [0, 0], 'k-'); title('Linear Convolution x[n]*h[n]'); xlabel('n'); ylabel('y[n]');endfunction function [result]=custom_mod(a, b) result = a - b * floor(a / b);endfunction Figure (a) LAB 4.1 Figure (b) LAB 4.1 Figure (c) LAB 4.1 ECE 34- LAB 4.2 Code: function autocorrelation(x) x_reversed = x(length(x):-1:1); y = convol(x, x_reversed); L = 0:length(x)-1; M = 1:length(x); N = 0:length(y)-1; printf('\nResult of autocorrelation:\n'); disp(y); // Plot x[n], x[n -1], and y[n] clf; subplot(3, 1, 1); plot(L, x, 'b-', 'linewidth', 2, 'Marker', 'o'); plot([L; L], [zeros(1, length(x)); x], 'b--'); plot([min(L), max(L)], [0, 0], 'k-'); title('Input Signal x[n]'); xlabel('n'); ylabel('x[n]'); subplot(3, 1, 2); plot(M, x, 'r-', 'linewidth', 2, 'Marker', 'o'); plot([M; M], [zeros(1, length(x)); x], 'r--'); plot([min(L), max(L)], [0, 0], 'k-'); title('Delayed Version of x[n]'); xlabel('n'); ylabel('x[n-n_d]'); subplot(3, 1, 3); plot(N, y, 'g-', 'linewidth', 2, 'Marker', 'o'); plot([min(N), max(N)], [0, 0], 'k-'); plot([N; N], [zeros(1, length(y)); y], 'g--'); title('Autocorrelation of x[n]'); xlabel('n'); ylabel('y[n]');endfunction Figure (a) LAB 4.2 Figure (b) LAB 4.2 Figure (c) LAB 4.2 ===================================================================== ECE 34- LAB 4.3 Code: function cross_correlation(x, h) h_reversed = h(length(h):-1:1);y = convol(x, h_reversed); L = 0:(length(x)-1); M = 0:(length(h)-1); N = 0:(length(y)-1); printf('\nResult of cross-correlation:\n'); disp(y); // Plot x[n], h[n], and y[n] clf; subplot(3, 1, 1); plot(L, x, 'b-', 'linewidth', 2, 'Marker', 'o'); plot([L; L], [zeros(1, length(x)); x], 'b--'); plot([0, length(x)-1], [0, 0], 'k-'); title('Input Signal x[n]'); xlabel('n'); ylabel('x[n]'); subplot(3, 1, 2); plot(M, h, 'r-', 'linewidth', 2, 'Marker', 'o'); plot([M; M], [zeros(1, length(h)); h], 'r--'); plot([0, length(h)-1], [0, 0], 'k-'); title('System Function h[n]'); xlabel('n'); ylabel('h[n]'); subplot(3, 1, 3); plot(N, y, 'g-', 'linewidth', 2, 'Marker', 'o'); plot([N; N], [zeros(1, length(y)); y], 'g--'); plot([0, length(y)-1], [0, 0], 'k-'); title('Cross-Correlation of x[n] and h[n]'); xlabel('n'); ylabel('y[n]');endfunction Figure (a) LAB 4.3 Figure (b) LAB 4.3 Figure (c) LAB 4.3