Beruflich Dokumente
Kultur Dokumente
INDEX
COMMAND WINDOW:
Enter values for a: [2 3 1 4 1]
Enter values for b: [1 1 4 2 7]
c=3 4 5 6 8
lenc = 1 5
length = 5
y=1 2 3 4 5
OUTPUT FIGURE:
Addition of matrices
5
4
Amplitude
0
3 4 5 6 7 8
X-axis
UE158074
CODE:
clear all;
clc;
x = -10:1:10
impulse = x==0
stem(x,impulse);
xlabel('Indices')
ylabel('Amplitude')
title('Impulse function')
OUTPUT FIGURE:
Matrix Addition
1
0.9
0.8
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Indices
UE158074
CODE:
clear all;
clc;
x = -10:1:10
unit_step = x>=0
stem(x,unit_step);
xlabel('Indices')
ylabel('Amplitude')
title('Unit step function')
OUTPUT FIGURE:
0.9
0.8
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Indices
UE158074
PROGRAM 2C: FOLD THE UNIT STEP FUNCTION AROUND THE ORIGIN
AND PLOT IT.
CODE:
clear all;
clc;
x = -10:1:10
unit_step = x<=0
stem(x,unit_step);
xlabel('Indices')
ylabel('Amplitude')
title('Unit step function after folding')
OUTPUT FIGURE:
0.9
0.8
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0
-10 -8 -6 -4 -2 0 2 4 6 8 10
Indices
UE158074
CODE:
clear all;
clc;
x1=input('input x1 values:');
x2=input('input x2 values:');
len1=size(x1);
len2=size(x2);
l1=len1(1,2);
l2=len2(1,2);
n1=input('enter origin of first signal: ');
n2=input('enter origin of second signal: ');
i=-(n1-1):1:l1-n1;
j=-(n2-1):1:l2-n2;
stem(i,x1);
figure;
stem(j,x2);
COMMAND WINDOW:
input x1 values:[1 5 7 3 2]
input x2 values:[1 1 2 2 3 5 7]
OUTPUT FIGURE 1:
OUTPUT FIGURE 2:
UE158074
CODE:
clear all;
clc;
x1=input('input x1 values:');
x2=input('input x2 values:');
len1=size(x1);
len2=size(x2);
l1=len1(1,2);
l2=len2(1,2);
n1=input('enter origin of first signal: ');
n2=input('enter origin of second signal: ');
a1=input('shift signal 1 by how much units : ');
a2=input('shift signal by how much units : ');
i=-(n1-1)+a1:1:(l1-n1)+a1;
j=-(n2-1)+a2:1:(l2-n2)+a2;
stem(i,x1);
figure;
stem(j,x2);
COMMAND WINDOW:
input x1 values:[1 5 7 3 2]
input x2 values:[1 1 2 2 3 5 7]
enter origin of first signal: 1
enter origin of second signal: 4
shift signal 1 by how much units : -2
shift signal by how much units : 3
UE158074
OUTPUT FIGURE 1:
OUTPUT FIGURE 2:
UE158074
PROGRAM 5: FOLD THE SIGNAL AROUND THE ORIGIN AND PLOT IT.
CODE:
clear all;
clc;
x1=input('input x1 values: ');
n=input('enter origin: ');
len1=size(x1);
l1=len1(1,2);
i=-(l1-n):1:(n-1);
b=fliplr(x1);
stem(i,b);
COMMAND WINDOW:
input x1 values: [1 2 3 4 5]
enter origin: 2
OUTPUT FIGURE:
UE158074
4.5
3.5
2.5
1.5
0.5
0
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1
UE158074
CODE:
clear all;
clc;
n=0:0.001:1
x=sin(2*n*50*pi);
plot(x);
y=fft(x);
z=abs(y);
plot(z);
grid on;
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 200 400 600 800 1000 1200
UE158074
500
450
400
350
300
250
200
150
100
50
0
0 200 400 600 800 1000 1200
464.6
464.4
464.2
464
463.8
463.6
463.4
CODE:
clear all;
clc;
p=0.05;
s=0.04;
fs=2000;
fp=1500;
Fs=9000;
x=-20*log(sqrt(p*s))-13;
y=(14.6*(fs-fp))/Fs;
N=ceil(x/y);
disp(N);
y1=rectwin(N);
b=fir1(N,[0.3 0.4],'stop');
freqz(b,1,256);
title('fir bandstop filter');
OUTPUT FIGURE:
-20
-40
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
0
Phase (degrees)
-2000
-4000
-6000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
UE158074
CODE:
clear all;
clc;
p=0.05;
s=0.04;
fs=2000;
fp=1500;
Fs=9000;
x=-20*log(sqrt(p*s))-13;
y=(14.6*(fs-fp))/Fs;
N=ceil(x/y);
disp(N);
y1=rectwin(N);
b=fir1(N,0.4,'low');
freqz(b,1,256);
title('fir lowpass filter');
OUTPUT FIGURE:
-50
-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
0
Phase (degrees)
-1000
-2000
-3000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
UE158074
CODE:
clear all;
clc;
p=0.05;
s=0.04;
fs=2000;
fp=1500;
Fs=9000;
x=-20*log(sqrt(p*s))-13;
y=(14.6*(fs-fp))/Fs;
N=ceil(x/y);
disp(N);
y1=rectwin(N);
b=fir1(N,0.3,'high');
freqz(b,1,256);
title('fir highpass filter');
OUTPUT FIGURE:
-50
-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
2000
Phase (degrees)
-2000
-4000
-6000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
UE158074
CODE:
clear all;
clc;
p=0.05;
s=0.04;
fs=2000;
fp=1500;
Fs=9000;
x=-20*log(sqrt(p*s))-13;
y=(14.6*(fs-fp))/Fs;
N=ceil(x/y);
disp(N);
y1=rectwin(N);
b=fir1(N,[0.3 0.4],'bandpass');
freqz(b,1,256);
title('fir bandpass filter');
OUTPUT FIGURE:
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)
500
Phase (degrees)
-500
-1000
-1500
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized Frequency ( rad/sample)