EXPERIMNET-10
IMPLEMENTATION OF HP FIR FILTER FOR GIVEN
SEQUENCE /SIGNAL
PROGRAM:-
clc;
clear all;
close all;
n = 20;
fp = 200;
fq = 300;
fs = 1000;
fn = 2*fp/fs;
window = blackman(n+1);
b = fir1(n, fn, 'high', window);
[H w] = freqz(b, 1, 128);
subplot(2,1,1);
plot(w/pi, abs(H));
title('Magnitude response of HPF');
ylabel('Gain in dB --->');
xlabel('Normalised frequency --->');
subplot(2,1,2);
plot(w/pi, angle(H));
title('Phase response of HPF');
ylabel('Angle --->');
xlabel('Normalised frequency --->');
OUTPUT:-
Gain in dB --->
Angle --->
RESULT:-HP FIR filter is designed ,magnitudeand phase plots have been
plotted
EXPERIMNET-11
IMPLEMENTATION OF HP IIR FILTER FOR GIVEN
SEQUENCE /SIGNAL
Program:-
clc;
clear all;
close all;
disp('Enter the IIR Filter design specification');
rp = input('Enter the passband ripple: ');
rs = input('Enter the stopband ripple: ');
wp = input('Enter the passband frequency: ');
ws = input('Enter the stopband frequency: ');
fs = input('Enter the sampling frequency: ');
w1 = 2*wp/fs;
w2 = 2*ws/fs;
[n, wn] = buttord(w1, w2, rp, rs);
disp('Frequency response of IIR HPF is');
[b,a] = butter(n, wn, 'high');
w = 0:0.01:pi;
[h, om] = freqz(b, a, w);
m = 20*log10(abs(h));
an = angle(h);
figure;
subplot(2,1,1);
plot(om/pi, m);
title('Magnitude response of IIR filter');
xlabel('Normalised frequency --->');
ylabel('Gain in dB --->');
subplot(2,1,2);
plot(om/pi, an);
title('Phase response of IIR filter');
xlabel('Normalised frequency --->');
ylabel('Phase in radians --->');
INPUT:-
Enter the passband ripple = 1
enter the stopband ripple = 40
enter the passband frequency = 3000
enter the stopband frequency = 1500
enter the sampling frequency = 8000
OUTPUT:-
Gain in dB --->
Phase in radians --->
RESULT:- HP IIR filter is designed ,magnitudeand phase plots have been
plotted
EXPERIMENT-12
Generation of sinusoidal signal through filtering
Program:-
close all;
clear all;
b = [1];
a = [1 -1 0.9];
n = [-20:120];
t = 0:0.1:2*pi;
x = sin(t);
s = filter(b,a,x);
stem(t,s);
title('sinusoidal response');
xlabel('n');
ylabel('s(n)');
OUTPUT:-
s(n)
RESULT:- Generation of sinusoidal signal through filtering
has been done using MATLAB
EXPERIMENT-14
Implementation of Decimation process
Program:-
clc;
clear all;
close all;
D = input('enter the downsampling factor');
L = input('enter the length of the input signal');
f1 = input('enter the frequency of first sinusoidal');
f2 = input('enter the frequency of second sinusoidal');
n = 0:L-1;
x = sin(2*pi*f1*n) + sin(2*pi*f2*n);
y = decimate(x,D,'fir');
subplot(2,1,1);
stem(n,x(1:L));
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
INPUT:-
enter the downsampling factor = 5
enter the length of the input signal = 100
enter the frequency of first sinusoidal = 0.01
enter the frequency of second sinusoidal = 0.03
OUTPUT:-
amplitude
amplitude
RESULT:- Implementation of Decimation process has been
done by using MATLAB
EXPERIMENT-15
Implementation of Interpolation process
Program:-
clc;
clear all;
close all;
L = input('enter the upsampling factor');
N = input('enter the length of the input signal');
f1 = input('enter the frequency of first sinusoidal');
f2 = input('enter the frequency of second sinusoidal');
n = 0:N-1;
x = sin(2*pi*f1*n) + sin(2*pi*f2*n);
y = interp(x,L);
subplot(2,1,1)
stem(n,x(1:N))
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m = 0:N*L-1;
stem(m,y(1:N*L))
title('output sequence');
xlabel('time(n)');
ylabel('amplitude');
INPUT:-
enter the upsampling factor = 5
enter the length of the input signal = 9
enter the frequency of first sinusoidal = 0.1
enter the frequency of second sinusoidal = 0.3
OUPUT:-
amplitude
amplitude
RESULT:- Implementation of Interpolation process has been
done by using MATLAB
EXPERIMENT-16
Implementation of I\D sampling rate converters
Program:-
clc;
clear all;
close all;
L = input('enter the upsampling factor');
D = input('enter the downsampling factor');
N = input('enter the length of the input signal');
f1 = input('enter the frequency of first sinusoidal');
f2 = input('enter the frequency of second sinusoidal');
n = 0:N-1;
x = sin(2*pi*f1*n) + sin(2*pi*f2*n);
y = resample(x,L,D);
subplot(2,1,1)
stem(n,x(1:N));
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m = 0:N*L/D-1;
stem(m,y(1:N*L/D));
title('output sequence');
xlabel('time(n)');
ylabel('amplitude');
INPUT:-
enter the upsampling factor = 3
enter the downsampling factor = 2
enter the length of the input signal = 40
enter the frequency of first sinusoidal = 0.01
enter the frequency of second sinusoidal = 0.03
OUTPUT:-
amplitude
amplitude
RESULT:- Implementation of I\D sampling rate converters
has been done by using MATLAB
EXPERIMENT-17
Impulse response of first order and second order
systems
Program:-
clc;
close all;
clear all;
n = 0:10;
b = [2 0 0];
a = [1 -0.9 0];
y = dimpulse(b,a,length(n));
subplot(2,1,1);
stem(n,y);
xlabel('n --->');
ylabel('amplitude');
title('impulse response of first order system');
b = [1 0 0];
a = [1 0.6 -0.8];
y1 = dimpulse(b,a,length(n));
subplot(2,1,2);
stem(n,y1);
xlabel('n --->');
ylabel('amplitude');
title('impulse response of second order system');
OUTPUT:-
amplitude
amplitude
RESULT:-Impulse response of first order and second order
systems has been done by MATLAB
EXPERIMENT-13
Generation of DTMF signals
Program:-
clear all;
close all;
t = -2:0.05:2;
x = input('enter the input number');
fo1 = 697;
fo2 = 770;
fo3 = 852;
fo4 = 941;
fc1 = 1209;
fc2 = 1336;
fc3 = 1477;
fc4 = 1633;
y0 = sin(2*pi*fo4*t) + sin(2*pi*fc2*t);
y1 = sin(2*pi*fo1*t) + sin(2*pi*fc1*t);
y2 = sin(2*pi*fo1*t) + sin(2*pi*fc2*t);
y3 = sin(2*pi*fo1*t) + sin(2*pi*fc3*t);
y4 = sin(2*pi*fo2*t) + sin(2*pi*fc1*t);
y5 = sin(2*pi*fo2*t) + sin(2*pi*fc2*t);
y6 = sin(2*pi*fo2*t) + sin(2*pi*fc3*t);
y7 = sin(2*pi*fo3*t) + sin(2*pi*fc1*t);
y8 = sin(2*pi*fo3*t) + sin(2*pi*fc2*t);
y9 = sin(2*pi*fo3*t) + sin(2*pi*fc3*t);
y_start = sin(2*pi*fo4*t) + sin(2*pi*fc1*t);
y_cancel = sin(2*pi*fo4*t) + sin(2*pi*fc3*t);
if (x == 1)
plot(t,y1)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 2)
plot(t,y2)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 3)
plot(t,y3)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 4)
plot(t,y4)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 5)
plot(t,y5)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 6)
plot(t,y6)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 7)
plot(t,y7)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 8)
plot(t,y8)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 9)
plot(t,y9)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 0)
plot(t,y0)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 11)
plot(t,y_start)
xlabel('time(t)')
ylabel('amplitude')
elseif (x == 12)
plot(t,y_cancel)
xlabel('time(t)')
ylabel('amplitude')
else
disp('enter the correct input')
end
INPUT:-
enter the input number = 5
OUTPUT:-
0.8
0.6
0.4
0.2
amplitude
-0.2
-0.4
-0.6
-0.8
-1
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
time(t)
RESULT:- Generation of DTMF signals has been done using
MATLAB