Linear Convolution-1
Linear Convolution-1
clc;
clear;
% Input sequences
x = input('Enter the first sequence x[n]: ');
h = input('Enter the second sequence h[n]: ');
% Plot x[n]
n = 0:lx-1;
subplot(3, 1, 1);
stem(n, x, 'filled');
title('Input Sequence x[n]');
xlabel('n');
ylabel('x[n]');
grid on;
% Plot h[n]
n = 0:lh-1;
subplot(3, 1, 2);
stem(n, h, 'filled');
title('Input Sequence h[n]');
xlabel('n');
ylabel('h[n]');
grid on;
clc;
clear;
y = conv(x, h);
lx = length(x);
lh = length(h);
ly = lx + lh - 1; % Length of the resulting sequence
% Plot x[n]
n=0:lx-1;
subplot(3, 1, 1);
stem(n, x, 'filled');
title('Input Sequence x[n]');
xlabel('n');
ylabel('x[n]');
grid on;
% Plot h[n]
n=0:lh-1;
subplot(3, 1, 2);
stem(n, h, 'filled');
title('Input Sequence h[n]');
xlabel('n');
ylabel('h[n]');
grid on;