%program For Convolution of Two Sequences X (N) and H (N)
%program For Convolution of Two Sequences X (N) and H (N)
clear all
x=[1,0,1,2,-1,3,2];
N1=length(x);
n=0:1:N1-1;
subplot(2,2,1),stem(n,x);
xlabel('n'),ylabel('x(n)');
h=[1,1,2,2,1,1];
N2=length(h);
n=0:1:N2-1;
subplot(2,2,2);stem(n,h);
xlabel('n'),ylabel('h(n)');
y=conv(x,h)
n2=0:1:N1+N2-2;
subplot(2,1,2),stem(n2,y);
xlabel('n'),ylabel('y(n)');
title('convolution of two sequences x(n)and h(n)');
OUTPUT:
3 2
2 1.5
h(n)
x(n)
1 1
0 0.5
-1 0
0 2 4 6 0 2 4 6
n n
convolution of two sequences x(n)and h(n)
15
10
y(n)
0
0 2 4 6 8 10 12
n
%To Generate a Unit Step Sequence
N=21;
x=ones(1,N);
n=0:1:(N-1);
subplot(2,2,1),stem(n,x);
xlabel('n'),ylabel('x(n)');
title('Unit step sequence')
0.5
x1(n)
x(n)
0.5 0
-0.5
0 -1
0 5 10 15 20 0 5 10 15 20
n n
Exponential sequence Addition of two sinusoidal sequences
1 2
1
x2(n)
x3(n)
0.5 0
-1
0 -2
0 5 10 15 20 0 5 10 15 20
n n
%Program to find Z-Transform of the Function
syms n;
X=n^2;
ztrans(X)
syms a,n;
y=a^n;
ztrans(y)
syms a,n;
X1=sin(a*n)
ztrans(X1)
syms a,n;
X2=cos(a*n)
ztrans(X2)
OUTPUT:
clear all
b=[2];
a=[1 3 2];
f=1;
[bz,az]=bilinear(b,a,f)
OUTPUT:
b=[1 2];
a=[1 5 11 15];
f=5;
[bz,az]=impinvar(b,a,f)
OUTPUT :
bz =-0.0000 0.0290 -0.0195