You are on page 1of 21

Department of Electronics Engineering ..........................................................................................

1
Mutirate signal processing ............................................................................................................. 1
Sine wave Decimate ...................................................................................................................... 2
Cosine wave Decimate ................................................................................................................... 5
Interpolation ................................................................................................................................. 8
Down Sampling.............................................................................................................................. 9
Upsampling ................................................................................................................................. 10
Interpolation ............................................................................................................................... 11
Resampling changes quantisation level ........................................................................................ 12
Exercise: Upsample a signal by 5 and then downsample by 5 and verify x=y ................................ 13
Down sample by 5 and upsample by 5 and verify x is not equal to 5 ............................................ 15
enter signal upsample by 20 and then down sample by 5 is equal ................................................ 16
Department of Electronics Engineering
%Yeshwantrao Chavan College of Engineering
%Name:CHETAN SETIYA
%Roll no :143
%Reg no :20010248
%Batch : B3
%Date of performance:07/11/2022
%Experiment no: 8

Mutirate signal processing


x=1:50;
D=2;
xd=decimate(x,4);
subplot(2,1,1)
stem(x)
title('Orignal Signal')
subplot(2,1,2)
stem(xd)
title('Decimated Signal')
Sine wave Decimate
n=0:0.01:1
x=sin(2*pi*6*n)
D=2;
xd=decimate(x,3);
subplot(2,1,1)
stem(x)
title('Orignal Signal')
subplot(2,1,2)
stem(xd)
title('Decimated Signal')

n =

Columns 1 through 7

0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600

Columns 8 through 14

0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300

Columns 15 through 21

0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000

Columns 22 through 28
0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700

Columns 29 through 35

0.2800 0.2900 0.3000 0.3100 0.3200 0.3300 0.3400

Columns 36 through 42

0.3500 0.3600 0.3700 0.3800 0.3900 0.4000 0.4100

Columns 43 through 49

0.4200 0.4300 0.4400 0.4500 0.4600 0.4700 0.4800

Columns 50 through 56

0.4900 0.5000 0.5100 0.5200 0.5300 0.5400 0.5500

Columns 57 through 63

0.5600 0.5700 0.5800 0.5900 0.6000 0.6100 0.6200

Columns 64 through 70

0.6300 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900

Columns 71 through 77

0.7000 0.7100 0.7200 0.7300 0.7400 0.7500 0.7600

Columns 78 through 84

0.7700 0.7800 0.7900 0.8000 0.8100 0.8200 0.8300

Columns 85 through 91

0.8400 0.8500 0.8600 0.8700 0.8800 0.8900 0.9000

Columns 92 through 98

0.9100 0.9200 0.9300 0.9400 0.9500 0.9600 0.9700

Columns 99 through 101

0.9800 0.9900 1.0000

x =

Columns 1 through 7

0 0.3681 0.6845 0.9048 0.9980 0.9511 0.7705

Columns 8 through 14

0.4818 0.1253 -0.2487 -0.5878 -0.8443 -0.9823 -0.9823

Columns 15 through 21
-0.8443 -0.5878 -0.2487 0.1253 0.4818 0.7705 0.9511

Columns 22 through 28

0.9980 0.9048 0.6845 0.3681 0.0000 -0.3681 -0.6845

Columns 29 through 35

-0.9048 -0.9980 -0.9511 -0.7705 -0.4818 -0.1253 0.2487

Columns 36 through 42

0.5878 0.8443 0.9823 0.9823 0.8443 0.5878 0.2487

Columns 43 through 49

-0.1253 -0.4818 -0.7705 -0.9511 -0.9980 -0.9048 -0.6845

Columns 50 through 56

-0.3681 -0.0000 0.3681 0.6845 0.9048 0.9980 0.9511

Columns 57 through 63

0.7705 0.4818 0.1253 -0.2487 -0.5878 -0.8443 -0.9823

Columns 64 through 70

-0.9823 -0.8443 -0.5878 -0.2487 0.1253 0.4818 0.7705

Columns 71 through 77

0.9511 0.9980 0.9048 0.6845 0.3681 0.0000 -0.3681

Columns 78 through 84

-0.6845 -0.9048 -0.9980 -0.9511 -0.7705 -0.4818 -0.1253

Columns 85 through 91

0.2487 0.5878 0.8443 0.9823 0.9823 0.8443 0.5878

Columns 92 through 98

0.2487 -0.1253 -0.4818 -0.7705 -0.9511 -0.9980 -0.9048

Columns 99 through 101

-0.6845 -0.3681 -0.0000


Cosine wave Decimate
n=0:0.01:1
x=cos(2*pi*6*n)
D=2;
xd=decimate(x,3);
subplot(2,1,1)
stem(x)
title('Orignal Signal')
subplot(2,1,2)
stem(xd)
title('Decimated Signal')

n =

Columns 1 through 7

0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600

Columns 8 through 14

0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300

Columns 15 through 21

0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000

Columns 22 through 28
0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700

Columns 29 through 35

0.2800 0.2900 0.3000 0.3100 0.3200 0.3300 0.3400

Columns 36 through 42

0.3500 0.3600 0.3700 0.3800 0.3900 0.4000 0.4100

Columns 43 through 49

0.4200 0.4300 0.4400 0.4500 0.4600 0.4700 0.4800

Columns 50 through 56

0.4900 0.5000 0.5100 0.5200 0.5300 0.5400 0.5500

Columns 57 through 63

0.5600 0.5700 0.5800 0.5900 0.6000 0.6100 0.6200

Columns 64 through 70

0.6300 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900

Columns 71 through 77

0.7000 0.7100 0.7200 0.7300 0.7400 0.7500 0.7600

Columns 78 through 84

0.7700 0.7800 0.7900 0.8000 0.8100 0.8200 0.8300

Columns 85 through 91

0.8400 0.8500 0.8600 0.8700 0.8800 0.8900 0.9000

Columns 92 through 98

0.9100 0.9200 0.9300 0.9400 0.9500 0.9600 0.9700

Columns 99 through 101

0.9800 0.9900 1.0000

x =

Columns 1 through 7

1.0000 0.9298 0.7290 0.4258 0.0628 -0.3090 -0.6374

Columns 8 through 14

-0.8763 -0.9921 -0.9686 -0.8090 -0.5358 -0.1874 0.1874

Columns 15 through 21
0.5358 0.8090 0.9686 0.9921 0.8763 0.6374 0.3090

Columns 22 through 28

-0.0628 -0.4258 -0.7290 -0.9298 -1.0000 -0.9298 -0.7290

Columns 29 through 35

-0.4258 -0.0628 0.3090 0.6374 0.8763 0.9921 0.9686

Columns 36 through 42

0.8090 0.5358 0.1874 -0.1874 -0.5358 -0.8090 -0.9686

Columns 43 through 49

-0.9921 -0.8763 -0.6374 -0.3090 0.0628 0.4258 0.7290

Columns 50 through 56

0.9298 1.0000 0.9298 0.7290 0.4258 0.0628 -0.3090

Columns 57 through 63

-0.6374 -0.8763 -0.9921 -0.9686 -0.8090 -0.5358 -0.1874

Columns 64 through 70

0.1874 0.5358 0.8090 0.9686 0.9921 0.8763 0.6374

Columns 71 through 77

0.3090 -0.0628 -0.4258 -0.7290 -0.9298 -1.0000 -0.9298

Columns 78 through 84

-0.7290 -0.4258 -0.0628 0.3090 0.6374 0.8763 0.9921

Columns 85 through 91

0.9686 0.8090 0.5358 0.1874 -0.1874 -0.5358 -0.8090

Columns 92 through 98

-0.9686 -0.9921 -0.8763 -0.6374 -0.3090 0.0628 0.4258

Columns 99 through 101

0.7290 0.9298 1.0000


Interpolation
x=1:50;
L=2;
xd=interp(x,2);
subplot(2,1,1)
stem(x)
title('Orignal Signal')
subplot(2,1,2)
stem(xd)
title('Interpolated Signal')
Down Sampling
x=[1,2,3,4,5,6,7];
D=2
xd=downsample(x,D)
subplot(2,1,1)
stem(x)
title('Orignal Signal')
subplot(2,1,2)
stem(xd)
title('Downsampled Signal')

D =

xd =

1 3 5 7
Upsampling
L=2
X=[1,2,3,4,5,6,7,8]
XL=upsample(X,L)

L =

X =

1 2 3 4 5 6 7 8

XL =

Columns 1 through 13

1 0 2 0 3 0 4 0 5 0 6 0 7

Columns 14 through 16

0 8 0
Interpolation
x=1:25;
L=2;
xL=upsample(x,L)
xd=interp(x,L)
subplot(2,2,1)
stem(x)
title('Orignal Signal')
subplot(2,2,2)
stem(xL)
title('Upsample Signal')
subplot(2,2,[3,4])
stem(xd)
title('Interpolated signal')

xL =

Columns 1 through 13

1 0 2 0 3 0 4 0 5 0 6 0 7

Columns 14 through 26

0 8 0 9 0 10 0 11 0 12 0 13 0

Columns 27 through 39

14 0 15 0 16 0 17 0 18 0 19 0 20

Columns 40 through 50

0 21 0 22 0 23 0 24 0 25 0

xd =

Columns 1 through 7

1.0000 1.4996 2.0000 2.4993 3.0000 3.4990 4.0000

Columns 8 through 14

4.4987 5.0000 5.4984 6.0000 6.4982 7.0000 7.4979

Columns 15 through 21

8.0000 8.4976 9.0000 9.4973 10.0000 10.4970 11.0000

Columns 22 through 28

11.4967 12.0000 12.4965 13.0000 13.4962 14.0000 14.4959

Columns 29 through 35

15.0000 15.4956 16.0000 16.4953 17.0000 17.4950 18.0000


Columns 36 through 42

18.4948 19.0000 19.4945 20.0000 20.4942 21.0000 21.4939

Columns 43 through 49

22.0000 22.4936 23.0000 23.4934 24.0000 24.4931 25.0000

Column 50

25.4928

Resampling changes quantisation level


clc
x=[1,2,3,4,5,6,7]
L=2
D=3
xd=resample(x,L,D)
subplot(2,1,1)
stem(x)
title('Orignal Signal')
subplot(2,1,2)
stem(xd)
title('Resampled Signal')

x =
1 2 3 4 5 6 7

L =

D =

xd =

0.8525 2.6513 3.7929 5.8816 5.7360

Exercise: Upsample a signal by 5 and then downsample by 5 and verify x=y


X=[1,2,3,4,5,6,7,8]
L=5
XL=upsample(X,L)
D=5
xd=downsample(XL,5)
subplot(2,2,1)
stem(X)
title('Orignal Signal')
subplot(2,2,2)
stem(XL)
title('Upsampled Signal')
subplot(2,2,[3,3])
stem(xd)
title('Downsample Signal')
y=xd
if(X==y)
disp('X==y')
else
disp('not same')
end

X =

1 2 3 4 5 6 7 8

L =

XL =

Columns 1 through 13

1 0 0 0 0 2 0 0 0 0 3 0 0

Columns 14 through 26

0 0 4 0 0 0 0 5 0 0 0 0 6

Columns 27 through 39

0 0 0 0 7 0 0 0 0 8 0 0 0

Column 40

D =

xd =

1 2 3 4 5 6 7 8

y =

1 2 3 4 5 6 7 8

X==y
Down sample by 5 and upsample by 5 and verify x is not equal to 5
X=[1,2,3,4,5,6,7,8,0,0]
D=5
xd=downsample(X,D)
L=5
XL=upsample(xd,5)
subplot(2,2,1)
stem(X)
title('Orignal Signal')
subplot(2,2,2)
stem(xd)
title('Upsampled Signal')
subplot(2,2,[3,3])
stem(XL)
title('Downsample Signal')
y=XL
if(X==y)
disp('X==y')
else
disp('not same')
end

X =

1 2 3 4 5 6 7 8 0 0

D =
5

xd =

1 6

L =

XL =

1 0 0 0 0 6 0 0 0 0

y =

1 0 0 0 0 6 0 0 0 0

not same

enter signal upsample by 20 and then down sample by 5 is equal


X=1:20
L=20
XL=upsample(X,L)
D=5
xd=downsample(XL,5)
XD=downsample(xd,4)
subplot(2,2,1)
stem(X)
title('Orignal Signal')
subplot(2,2,2)
stem(xd)
title('Upsampled by 20 and Downsampled by 5')
subplot(2,2,[3,3])
stem(XD)
title('Downsample Signal by 4')
y=XD
if(X==y)
disp('X==y')
else
disp('not same')
end

X =

Columns 1 through 13

1 2 3 4 5 6 7 8 9 10 11 12 13

Columns 14 through 20

14 15 16 17 18 19 20

L =

20

XL =

Columns 1 through 13

1 0 0 0 0 0 0 0 0 0 0 0 0

Columns 14 through 26

0 0 0 0 0 0 0 2 0 0 0 0 0

Columns 27 through 39

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 40 through 52

0 3 0 0 0 0 0 0 0 0 0 0 0

Columns 53 through 65

0 0 0 0 0 0 0 0 4 0 0 0 0
Columns 66 through 78

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 79 through 91

0 0 5 0 0 0 0 0 0 0 0 0 0

Columns 92 through 104

0 0 0 0 0 0 0 0 0 6 0 0 0

Columns 105 through 117

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 118 through 130

0 0 0 7 0 0 0 0 0 0 0 0 0

Columns 131 through 143

0 0 0 0 0 0 0 0 0 0 8 0 0

Columns 144 through 156

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 157 through 169

0 0 0 0 9 0 0 0 0 0 0 0 0

Columns 170 through 182

0 0 0 0 0 0 0 0 0 0 0 10 0

Columns 183 through 195

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 196 through 208

0 0 0 0 0 11 0 0 0 0 0 0 0

Columns 209 through 221

0 0 0 0 0 0 0 0 0 0 0 0 12

Columns 222 through 234

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 235 through 247

0 0 0 0 0 0 13 0 0 0 0 0 0

Columns 248 through 260


0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 261 through 273

14 0 0 0 0 0 0 0 0 0 0 0 0

Columns 274 through 286

0 0 0 0 0 0 0 15 0 0 0 0 0

Columns 287 through 299

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 300 through 312

0 16 0 0 0 0 0 0 0 0 0 0 0

Columns 313 through 325

0 0 0 0 0 0 0 0 17 0 0 0 0

Columns 326 through 338

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 339 through 351

0 0 18 0 0 0 0 0 0 0 0 0 0

Columns 352 through 364

0 0 0 0 0 0 0 0 0 19 0 0 0

Columns 365 through 377

0 0 0 0 0 0 0 0 0 0 0 0 0

Columns 378 through 390

0 0 0 20 0 0 0 0 0 0 0 0 0

Columns 391 through 400

0 0 0 0 0 0 0 0 0 0

D =

xd =

Columns 1 through 13

1 0 0 0 2 0 0 0 3 0 0 0 4
Columns 14 through 26

0 0 0 5 0 0 0 6 0 0 0 7 0

Columns 27 through 39

0 0 8 0 0 0 9 0 0 0 10 0 0

Columns 40 through 52

0 11 0 0 0 12 0 0 0 13 0 0 0

Columns 53 through 65

14 0 0 0 15 0 0 0 16 0 0 0 17

Columns 66 through 78

0 0 0 18 0 0 0 19 0 0 0 20 0

Columns 79 through 80

0 0

XD =

Columns 1 through 13

1 2 3 4 5 6 7 8 9 10 11 12 13

Columns 14 through 20

14 15 16 17 18 19 20

y =

Columns 1 through 13

1 2 3 4 5 6 7 8 9 10 11 12 13

Columns 14 through 20

14 15 16 17 18 19 20

X==y
Published with MATLAB® R2022a

You might also like