Windows
Windows
x = [1 2 2 1];
h = [1 2 1 0];
x1 = fft(x);
h1 = fft(h);
for i= 1:4
z(i) = x1(i)*h1(i);
end
display(z);
x = [1 2 2 1 0 0 0 0];
h = [1 2 1 0 0 0 0 0];
x1 = fft(x,8);
h1 = fft(h,8);
for i = 1:8
z(i) = x(i)*h(i);
end
display(z);
1 4 7 7 4 1 0
z =
ans =
5 5 7 7
y_linear =
1 4 7 7 4 1 0 0 0 0
0 0 0 0 0
z =
Columns 1 through 4
Columns 5 through 8
w_circular =
ans =
clc;
clear all;
close all;
wp = 2*fp/f;
ws = 2*fs/f;
subplot(2,2,1);
plot(ph/pi, m);
title('Fig. 1 Magnitude Plot of Analog Butterworth
Filter IIR LPF');
grid on;
subplot(2,2,2);
plot(ph/pi, y);
title('Fig.2 Phase Plot of Analog Butterworth Filter
IIR HPF');
grid on;
[bz, az] = bilinear(b,a,f)%% Matches the frequency to
normalized frequency
T = 1/f;
Hz = tf(bz, az, T)
[h1, ph1] = freqz(bz, az, 512,f);
m1 = 20*(log10 (abs(h1)));
y1 = angle(h1);
subplot(2,2,3);
plot(ph/pi, m1);
title('Fig. 3 Magnitude Plot of Digital Butterworth
Filter IIR HPF');
grid on;
%
subplot(2,2,4);
plot(ph/pi, y1);
title('Fig. 4 Phase Plot of Digital Butterworth Filter
IIR HPF');
grid on;
zplane(bz, az)
N=5
wn = 0.5778
Transfer function:
0.02716 s^5 - 0.1358 s^4 + 0.2716 s^3 - 0.2716 s^2 + 0.1358 s - 0.02716
-----------------------------------------------------------------------
s^5 + 0.7659 s^4 + 0.8389 s^3 + 0.2841 s^2 + 0.0883 s + 0.007964
OUTPUT WAVEFORM:
wp = 2*fp/f;
ws = 2*fs/f;
subplot(2,2,1);
plot(ph/pi, m);
title('Fig. 1 Magnitude Plot of Analog Butterworth Filter IIR
LPF');
grid on;
subplot(2,2,2);
plot(ph/pi, y);
title('Fig.2 Phase Plot of Analog Butterworth Filter IIR LPF');
grid on;
subplot(2,2,4);
plot(ph/pi, y1);
title('Fig. 4 Phase Plot of Digital Butterworth Filter IIR LPF');
grid on;
zplane(bz, az)
OUTPUT OF COMMAND WINDOW:
N=5
wn = 0.3421
Transfer function:
0.01177 s^5 + 0.05887 s^4 + 0.1177 s^3 + 0.1177 s^2 + 0.05887 s + 0.01177
-------------------------------------------------------------------------
Transfer function:
0.01178 z^5 - 0.05889 z^4 + 0.1178 z^3 - 0.1177 z^2 + 0.05886 z - 0.01177
-------------------------------------------------------------------------
>> fdatool
OUTPUT WAVEFORM:
Rectangular Window
clc;
close all;
clear all;
%%PROGRAM TO DESIGN RECTANGULAR WINDOW
rp=input('enter passband ripples:');
rs=input('enter stopband ripples:');
fp=input('enter passband frequency:');
fs=input('enter stopband frequency:');
f=input('enter sampling frequncy:');
wp=2*fp/f
ws=2*fs/f
num=-20*log10(sqrt(rp*rs))-13
den=14.6*(fs-fp)/f
n=ceil(num/den)%% reconstructs the original image
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end;
y=boxcar(n1);%% impulse response of the filter
subplot(2,1,1);
plot(y);
title('fig.1 magnitude plot of rectangular window');
grid on;
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);%%returns the complex frequency response
m=20*log10(abs(h));
subplot(2,1,2);
plot(o/pi,m);
grid on;
title('fig.2 magnitude response of digital LP FIR filter');
xlabel('normalized frequncy in dB');
ylabel('normalized gain in dB');
wp = 0.3000
ws = 0.6250
num = 15.2391
den =2.3725
n= 7
OUTPUT WAVEFORM:
%% Output Of Figure Window:
%% Output Of fdatool :
Kaiser Window
clc;
clear all;
close all;
OUTPUT:
OUTPUT OF COMMAND WINDOW:
wp = 0.4286
ws =0.7143
num = 17.9691
den =2.0857
n= 9
n1 = 10
y= 0.9157
0.9521
0.9786
0.9946
1.0000
0.9946
0.9786
0.9521
0.9157
OUTPUT WAVEFORM:
%% Output Of Figure Window:
%% Output Of fdatool :
Hanning Window
clc;
clear all;
close all;
OUTPUT:
OUTPUT OF COMMAND WINDOW:
wp = 0.4286
ws =0.7143
num = 17.9691
den = 2.0857
n=9
n1 = 10
OUTPUT WAVEFORM:
%% Output Of Figure Window:
%% Output Of fdatool :
Hamming Window
clc;
clear all;
close all;
wp =0.4286
ws =0.7143
num = 17.9691
den =2.0857
n=9
n1 = 10
y=
0.0800
0.2147
0.5400
0.8653
1.0000
0.8653
OUTPUT WAVEFORM:
%% Output Of fdatool :
Bartlet Window
clc;
close all;
clear all;
b = fir1(n,wp,y);
[h,o] = freqz(b,1,256)
m = 20*log10(abs(h));
subplot(2,1,2)
plot(o/pi, m)
grid on;
OUTPUT:
OUTPUT OF COMMAND WINDOW:
wp = 0.4286
ws =0.7143
num =17.9691
den =2.0857
n =9
n1 =10
y= 0
0.2500
0.5000
0.7500
1.0000
0.7500
0.500
0.2500
H=
1.0000
0.9988 - 0.0491i
0.9951 - 0.0980i
0.9889 - 0.1467i
0.9803 - 0.1950i
OUTPUT WAVEFORM:
%% Output Of Figure Window:
%% Output Of fdatool :
Blackman Window
clc;
close all;
clear all;
b = fir1(n,wp,y);
[h,o] = freqz(b,1,256)
m = 20*log10(abs(h));
subplot(2,1,2)
plot(o/pi, m)
grid on;
wp =0.4286
ws =0.7143
num = 17.9691
den = 2.0857
n=9
n1 =10
y =
-0.0000
0.0664
0.3400
0.7736
1.0000
0.7736
0.3400
0.0664
-0.0000
h=
1.0000
0.9988 - 0.0491i
0.9950 - 0.0980i
0.9888 - 0.1467i
0.9801 - 0.1949i
0.9689 - 0.2427i
OUTPUT WAVEFORM:
%% Output Of Figure Window:
%% Output Of fdatool :
Title:To Design and implement two stage sampling rate
converter.
Roll No:48
Up sampling factor=3
OUTPUT WAVEFORM:
EXAMPLE 1:
Enter sequence:n^2
OUTPUT WAVEFORM:
Pole Zero Plot:
Frequency Response:
EXAMPLE 2:
y =-z/(z + 1)^2
OUTPUT WAVEFORM:
Pole Zero Plot:
Frequency Response:
Title: Computation of DCT and IDCT of a discrete time
signal
Roll No:48
clc;
clear all;
close all;
fp = fopen('watermark.wav', 'r');%%o pen file, or obtain
information about open files
fseek(fp, 44, -1)%% Set file position indicator
a = fread(fp, 1024);%% Read binary data from file
plot(a);
hold on;
title('Plot of Original speech signal');
xlabel('sample number');
ylabel('Amplitude');
figure;
c = dct(a);%% Discrete cosine transform
plot(c);
hold on
title('Plot of frequency contents of speech signal in
DCT domain');
xlabel('DCT Coefficient number');
ylabel('Amplitude');
for i = 1:104
d1(i)= c(i);
end
for i = 105:1023
d1(i)= 0;
end
figure;
plot(d1);
title('Plot of frequency contents of speech signal
after LPF WINDOW TO PASS 1 TO 104 dct samples');
xlabel('DCT Coefficient number');
ylabel('Amplitude');