0% found this document useful (0 votes)
6 views6 pages

Exp2 Examples22

Uploaded by

adityashinde5578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Exp2 Examples22

Uploaded by

adityashinde5578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Upsampling Example :

Code :
N = input('Enter the sequence length : ');
L = input('Enter the upsampling factor : ');
n = 0:1:N-1;
x = cos(2*pi*n/15); %input sequence
y = interp(x,L); %upsampled signal
n1 = 1:1:L*N;

subplot(2,1,1)
stem(n,x);
grid;

subplot(2,1,2)
stem(n1,y);
grid;

Output
[For Values (100,2)]
1

0.5

-0.5

-1
0 10 20 30 40 50 60 70 80 90 100

0.5

-0.5

-1
0 20 40 60 80 100 120 140 160 180 200

Downsampling Example :

Code :
N = input('Enter the sequence length : ');
M = input('Enter the downsampling factor : ');
n = 0:1:N-1;
x = cos(2*pi*n/10) + cos(2*pi*n/5);
y = decimate(x,M);
n1 = 1:1:N/M;

subplot(2,1,1)
stem(n,x);
grid;

subplot(2,1,2)
stem(n1,y);
grid;
Output :

-1
0 10 20 30 40 50 60 70 80 90 100

0.5

-0.5

-1
0 5 10 15 20 25 30 35 40 45 50

Up sampling ex 2

N = input('Enter the sequence length: ');


L = input('Enter the upsampling factor: ');
n = 0:1:N-1;

% input sequence
x2 = sin(2*pi*n/10); % Input sequence
y2 = interp(x2, L); % Upsampled
signal
n2 = 1:1:L*N;
subplot(2, 2, 3)
stem(n, x2);
title('Input Sequence 2');
grid;

subplot(2, 2, 4)
stem(n2, y2);
title('Upsampled Signal 2');
grid;
Downsampling ex 2
N = input('Enter the sequence length: ');
M = input('Enter the downsampling factor: ');
n = 0:1:N-1;

% input sequence
x2 = sin(2*pi*n/10); % Input sequence
y2 = decimate(x2, M); % Downsampled signal
n2 = 0:M:N-1; % Downsampled indices for x2

subplot(2, 2, 3)
stem(n, x2);
title('Input Sequence 2');
grid;

subplot(2, 2, 4)
stem(n2, y2);
title('Downsampled Signal 2');
grid;

You might also like