Up Sampling and Down Sampling
Up Sampling and Down Sampling
input sequence
x(n)
Program:
clear all; x=input('enter the input sequence'); l=input('enter the sampling'); z=zeros(1,(l*length(x))); z([1:l:length(z)])=x; disp(z); subplot(3,1,2); stem(z); xlabel('n'); ylabel('x(n)'); title('up sampling'); y=x([1:l:length(x)]); disp(y); subplot(3,1,3); stem(y); xlabel('n'); ylabel('y(n)'); title('down sampling'); disp(x); subplot(3,1,1); stem(x); xlabel('n'); ylabel('x(n)'); title('input sequence');
1.5
2.5
3 3.5 n up sampling
4.5
5
x(n)
10
15 n down sampling
20
25
1
y(n)
0.5 0
0.2
0.4
0.6
0.8
1 n
1.2
1.4
1.6
1.8
Output:
enter the input sequence [ 1 2 3 4 5] enter the sampling>> 5 Columns 1 through 13 1 0 0 0 0 2 0 0 0 0 3 0 0 Columns 14 through 25 0 0 4 0 0 0 0 5 0 0 0 0 1 1 2 3 4 5
clear all; l=input('enter d length of input'); s=input('enter d sampling rate'); f=input('enter d frequency'); t=0:1/f:12; y=sin(t); subplot(3,1,1); stem(t,y); title('input sequence'); t0=0:1/(s*f):12; y0=sin(t0); subplot(3,1,2); stem(t0,y0); title('up sampled sequence'); t1=0:s/f:12; y1=sin(t1); subplot(3,1,3); stem(t1,y1); title('down sampled sequence');
0 -1 1 0 -1 1 0 -1
6 8 up sampled sequence
10
12
10
12
10
12
Output: