You are on page 1of 32

Q1: Write a MATLAB program to compute linear convolution of x(n) and h(n)

X(n)=(1+n) ^n, 0<=n<=4 h(n)=n^2, 0<=n<=4

0 , otherwise 0 , otherwise
clc;
clear all;
close all;
ln=0:1:4;
x=[1 2 9 64 625]
h=[0 1 4 9 16]
y=conv(x,h)
ly=0:length(y)-1;
subplot(3,1,1);
stem(ln,x);
xlabel('length of signal---->');
ylabel('x values -------->');
title('11803991');
subplot(3,1,2);
stem(ln,h);
xlabel('length of signal---->');
ylabel('h values -------->');
title('11803991');
subplot(3,1,3);
stem(ly,y);
xlabel('length of signal---->');
ylabel('y values -------->');
title('11803991');

RESULT:
x=
1 2 9 64 625
h=
0 1 4 9 16
y=
0 1 6 26 134 994 3220 6649 10000

GRAPH:
Q2: Write a program to find circular convolution of x(n) and h(n)? Where x(n) is the last four
digits of your registration number and h(n) is the first four digits of your registration number a)
Also plot the signal x, h and convolution output (i.e. y) by using subplot command. b) Title of
graph should be your name followed by signal name (e.g., MOHAN x, MOHAN h, MOHAN y) c)
Also write some xlabel and ylabel. which should be your registration number followed by some
name of graph (e.g., Label of x-axis and y-axis is shown as ‘11204316 Time ’and (‘11204316
input x(n) ’ respectively) (Hint: let’s your registration number is 11204316 then x = [4,3,1,6]
and h will be [1,1,2,0]) Also solve the question manually and verify with program.

PROGRAM:
clc;
clear all;
close all;
x=[0 9 6 6]
h=[1 1 8 0]
n=max(length(x),length(h));
N=0:1:3;
y=cconv(x,h,n)
subplot(3,1,1);
stem(N,x);
xlabel('11803991 time---->');
ylabel('11803991 input x(n)--->');
title('Mrityunjai singh x');
subplot(3,1,2);
stem(N,h);
xlabel('11803991 time---->');
ylabel('11803991 input h(n)--->');
title('Mrityunjai singh h');
subplot(3,1,3);
stem(N,y);
xlabel('11803991 time---->');
ylabel('11803991 input y(n)--->');
title('Mrityunjai singh y');

RESULT:

x=

0 9 6 6

h=

1 1 8 0

y=
54 57 15 84

GRAPH:
Q3: Write a program to find correlation of x(n) and h(n)? Where x(n) is the first four digits of
your registration number and h(n) is the last four digits of your registration number? a) Also
plot the signal x, h, and correlation output. b) Title of graph should be your registration
number followed by signal name (e.g., 11204316 x, 11204316 h, 11204316 y) c) Also write
some xlabel and ylabel which should be your name followed by some name of graph (e.g., Label
of x-axis and y-axis is shown as ‘MOHAN Time ’and (‘MOHAN input x(n) ’) (Hint: let’s your
registration number is 11204316 then x = [1,1,2,0] and h will be [4,3,1,6]). Also solve the
question manually and verify with program.

PROGRAM:
clc;
clear all;
close all;
x=[1 1 8 0]
h=[0 9 6 6]
a=0:1:3;
n=length(x)+length(h)-1;
N=0:1:n-1;
y=xcorr(x,h)
subplot(3,1,1);
stem(a,x);
xlabel('Mrityunjai singh time---->');
ylabel('Mrityunjai singh input x(n)--->');
title('11803991 x');
subplot(3,1,2);
stem(a,h);
xlabel('Mrityunjai singh time---->');
ylabel('Mrityunjai singh h(n)--->');
title('11803991 h');
subplot(3,1,3);
stem(N,y);
xlabel('Mrityunjai singh time---->');
ylabel('Mrityunjai singh input y(n)--->');
title('11803991 y');

RESULT:
x =

1 1 8 0

h =

3 9 9 1

y =

1 10 26 84 75 24 0

GRAPH:
Q4:Write a MATLAB program to plot two functions on the same figure: Function 1:- Generation
of sine wave of duration time = 10 sec with frequency =2 Hz and amplitude of 10. Function 2:- f
= 2n2+3n+5, where the variable n varies from 0 to 10 with step size of 0.01.
a) Plot the function 1 graph is in red color and function 2 graph is in green color.
b) Title of graph should be your registration number followed by Function name and also label
the axes.

PROGRAM:
clc;
clear all;
close all;
t=0:0.01:10;
f=2;
a=10;
n=t;
f1=a*sin(2*pi*f*t);
f2=((2*n.^2)+(3*n)+5);
hold on;
grid on;
stem(t,f1,'r');
stem(t,f2,'g');
xlabel('time period and n---->');
ylabel('functions f1 and f2--->');
title('11803991 f1=sine wave and f2=2n^2+3n+5');

RESULT:
THERE ARE 1001 RESULTS…
I AM NOT PASTING. BECAUSE IT OCCUPIES MORE SPACE.

GRAPH:
Q5: Write a MATLAB program to calculate the DFT of your roll no. as a sequence using FFT.
a) Give title to your graph as your name followed by your registration number and label
the axes. (Hint: let’s your registration number is 11204316 then x = [1 1 2 0 4 3 1 6].
Also solve the question manually and verify with program.

PROGRAM:
clc;
clear all;
close all;
x=[1 1 8 0 0 9 6 6];
n=0:length(x)-1;
x1=fft(x);
subplot(1,1,1);
stem(n,x1);
xlabel('length of signal---->');
ylabel('fft values of x (x1) -------->');
title(' Mrityunjai singh 11803991');

RESULT:

x =

1 1 8 0 3 9 9 1

x1 =

Columns 1 through 5

31.0000 + 0.0000i -0.4142 + 7.8995i -13.0000 - 4.0000i


2.4142 +11.8995i -1.0000 + 0.0000i

Columns 6 through 8

2.4142 -11.8995i -13.0000 + 4.0000i -0.4142 - 7.8995i

GRAPH:
Q6: Calculate the response of low-pass FIR filter using Hanning window. Also verify the results.
N=20; fp =100Hz; fs=1000.

PROGRAM:
clc;
clear all;
close all;
n=20;
fp=100;
fs=1000;
wp=(2*pi*fp/fs)
window=hann(n+1)
b=fir1(n,wp/pi,'low',window)
freqz(b,1);

RESULT:

window =

0
0.0245
0.0955
0.2061
0.3455
0.5000
0.6545
0.7939
0.9045
0.9755
1.0000
0.9755
0.9045
0.7939
0.6545
0.5000
0.3455
0.2061
0.0955
0.0245
0

b =

Columns 1 through 10

0 -0.0005 -0.0036 -0.0088 -0.0106 0.0000 0.0302


0.0791 0.1352 0.1802

Columns 11 through 20

0.1975 0.1802 0.1352 0.0791 0.0302 0.0000 -0.0106


-0.0088 -0.0036 -0.0005

Column 21
0
GRAPH:
+

Part B

You might also like