Let's explore discrete-time (DT) convolution using MATLAB's 'conv' command. We'll investigate a DT system with an impulse response h[n] = 0.7^n for 0 <= n <= 10, and an input sequence x[n] = u[n] - u[n-4].

a) Convolution Using MATLAB's conv Command

To plot the output y[n], we'll use the conv command in MATLAB:

n = 0:10; % Time index
h = 0.7.^n; % Impulse response
x = [ones(1, 5), zeros(1, 6)]; % Input sequence

y = conv(x, h); % Perform convolution

stem(n, y); % Plot output using stem command
xlabel('n');
ylabel('y[n]');
title('Convolution Output y[n]');

b) Manual Convolution Verification

We can verify the result by manually performing the convolution. This involves multiplying the sequences element-wise and summing the products. To simplify the process, we'll reverse the order of x[n] and perform the convolution:

n = 0:10; % Time index
h = 0.7.^n; % Impulse response
x = [ones(1, 5), zeros(1, 6)]; % Input sequence

% Reverse the order of x[n]
x_reversed = fliplr(x);

% Perform the convolution
y_by_hand = zeros(1, length(n));
for i = 1:length(n)
    y_by_hand(i) = sum(h(1:i) .* x_reversed(end-i+1:end));
end

% Plot the result
stem(n, y_by_hand);
xlabel('n');
ylabel('y[n]');
title('Convolution Output y[n] (by hand)');

By comparing the two plots, we can confirm that the output obtained using the conv command matches the result achieved through manual convolution. This comparison helps ensure the accuracy of our implementation.


原文地址: https://www.cveoy.top/t/topic/AUG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录