-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlinearConvolutionBothSide.m
More file actions
45 lines (38 loc) · 1.02 KB
/
linearConvolutionBothSide.m
File metadata and controls
45 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
% Plot the Linear Convolution of two sequence x[n] and h[n] (Right Sided Sequence)
% x=[1 0 -1 1 2 1];
% h=[1 1 1 1 1];
% Taking Input from user
x=input('Enter the input sequence x[n]=');
h=input("Enter the impulse sequence h[n]=");
a=input("Enter the starting point of x[n]=");
b=input("Enter the starting point of h[n]=");
n1=a:1:length(x)-1+a;
n2=b:1:length(h)-1+b;
%n1=0:1:length(x)-1;
%n2=0:1:length(h)-1;
n=(a+b):1:length(x)+length(h)-2+a+b;
y=conv(x, h);
disp('Linear Convolution of two sequence of y[n] = x[n]*h[n]');
disp(y);
subplot(3,1,1);
stem(n1, x);
xlabel("Time Domain(n)");
ylabel("Amplitude x[n]");
title("Input Sequence x[n]");
%axis([-2 6 -1.5 2.5]);
grid on;
subplot(3,1,2);
stem(n2, h);
xlabel("Time Domain(n)");
ylabel("Amplitude h[n]");
title("Impulse Sequence h[n]");
%axis([-1 5 -0.5 1.5]);
grid on;
subplot(3,1,3);
stem(n, y);
xlabel("Time Domain(n)");
ylabel("Amplitude y[n]");
title("Linear Convolution y[n]");
%axis([-1 10 -1 5]);
grid on;
sgtitle("Plot of Linear Convolution of two sequence y[n] = x[n]*h[n]");