Académique Documents
Professionnel Documents
Culture Documents
clear all
close all
n=[0:4];
x=[n==0];
stem(n,x)
x =
1 0 0 0 0
close all
clear all
N=21;
n=0:1:N-1;
subplot(5,1,1);
stem(n,sin(.1*pi*n))
title('sine1')
subplot(5,1,2)
stem(n,sin(.2*pi*n))
title('sine2')
x=sin(.1*pi*n)+sin(.2*pi*n)
subplot(5,1,3)
stem(n,x);
title('sum of two sinusoidal signals')
y=fft(x);
subplot(5,1,4)
f=0:1:N-1;
plot(f,abs(y));
title('magnitude vs frequency')
subplot(5,1,5)
plot(f,angle(y));
OUTPUT:
x =
Columns 1 through 16
Columns 17 through 21
WINDOWING TECHNIQUES:
KAISER WINDOW:
INPUT:
cutoff freq for HPF 800
sampling freq4000
order of filter4
OUTPUT:
b =
INPUT:
cutoff freq for LPF 800
sampling freq 4000
order of filter 4
OUTPUT:
b =
RECTANGULAR WINDOW:
b =
b =
HAMMIMG WINDOW:
INPUT;
OUTPUT:
b =
INPUT:
b =
FIR FILTERS:
CHEBYSHEV LPF:
clear all;
alphap=1;
alphas=15;
wp=0.2*pi;
ws=0.3*pi;
[n,wn]=cheb1ord(wp/pi,ws/pi,alphap,alphas)
[b,a]=cheby1(n,alphap,wn)
w=0:0.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);
plot(ph/pi,m);
ylabel('gain in dB');
xlabel('normalized frequency');
subplot(2,1,2);
plot(ph/pi,an);
ylabel('phase in radians');
xlabel('normalized frequency');
n =
wn =
0.2000
b =
a =
CHEBYSHEV HPF:
clear all;
alphap=1;
alphas=15;
wp=0.2*pi;
ws=0.3*pi;
[n,wn]=cheb1ord(wp/pi,ws/pi,alphap,alphas)
[b,a]=cheby1(n,alphap,wn,'high')
w=0:0.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);
plot(ph/pi,m);
ylabel('gain in dB');
xlabel('normalized frequency');
subplot(2,1,2);
plot(ph/pi,an);
ylabel('phase in radians');
xlabel('normalized frequency');
n =
wn =
0.2000
b =
a =
BUTTERWORTH HPF:
clear all;
alphap=0.4;
alphas=30;
fp=400;
fs=800;
f=2000;
omp=2*fp/f;
oms=2*fs/f;
[n,wn]=buttord(omp,oms,alphap,alphas)
[b,a]=butter(n,wn,'high')
w=0:0.1:pi;
[h,om]=freqz(b,a,w);
m=20*log(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('gain in dB');
xlabel('normalized frequency');
subplot(2,1,2);
plot(om/pi,an);
ylabel('phase in radians');
xlabel('normalized frequency');
n =
wn =
0.5821
b =
a =
BUTTERWORTH LPF:
clear all;
alphap=0.4;
alphas=30;
fp=400;
fs=800;
f=2000;
omp=2*fi/f;
oms=2*fs/f;
[n,wn]=buttord(omp,oms,alphap,alphas)
[b,a]=butter(n,wn)
w=0:0.01:pi;
[b,om]=freqz(b,a,w,whole);
m=abs(h);
an=angle(h);
subplot(2,1,1);
plot(om/pi,20*log(m));
ylabel('gain in dB');
xlabel('normalized frequency');
subplot(2,1,2);
plot(om/pi,an);
ylabel('phase in radians');
xlabel('normalized frequency');
1D AND 2D
%1D SEQUENCE
x=1:4
y=dct2(x)
subplot(2,1,1)
stem(x,y)
title('1D SEQUENCE')
xlabel('x(input)');
ylabel('y(dct output)');
%2D SEQUENCE
x=[1:4;5:8]
y=dct2(x,2,4)
subplot(2,1,2)
stem(x,y)
title('2D SEQUENCE')
xlabel('x(input)');
ylabel('y(dct output)');
x =
1 2 3 4
y =
x =
1 2 3 4
5 6 7 8
y =
n=0:0.025:1;
x=sin(2*pi*2*n)+sin(2*pi*4*n)
y=decimate(x,2)
subplot(4,1,1)
stem(n,sin(2*pi*4*n))
title('input sequence')
subplot(4,1,2)
stem(n,sin(2*pi*2*n))
title('input sequence')
subplot(4,1,3)
stem(y)
title('decimation')
z=interp(x,2)
subplot(4,1,4)
stem(z)
title('interpolation')
x =
Columns 1 through 16
Columns 17 through 32
Columns 33 through 41
y =
Columns 1 through 16
Columns 17 through 21
z =
Columns 1 through 16
Columns 17 through 32
Columns 33 through 48
Columns 49 through 64
Columns 65 through 80
0.3633 0.2931 0.1420 -0.0819 -0.3633 -0.6787 -1.0000 -1.2969
-1.5388 -1.7003 -1.7601 -1.7074 -1.5388 -1.2632 -0.8968 -0.4655
Columns 81 through 82
-0.0000 0.4655