MULTIRATE DIGITAL SIGNAL PROCESSING
Program to study the operation of a up-sampler.
% Program
% Illustration of Up-Sampling by an Integer Factor
%
clf;
n = 0:50;
x = sin(2*pi*0.12*n);
y = zeros(1, 3*length(x));
y([1: 3: length(y)]) = x;
subplot(2,1,1)
stem(n,x);
title(’Input Sequence’);
xlabel(’Time index n’);ylabel(’Amplitude’);
subplot(2,1,2)
stem(n,y(1:length(x)));
title(’Output Sequence’);
xlabel(’Time index n’);ylabel(’Amplitude’);
Program can be used to study the operation of a down-sampler.
% Program
% Illustration of Down-Sampling by an Integer Factor
%
clf;
n = 0: 49;
m = 0: 50*3 - 1;
x = sin(2*pi*0.042*m);
y = x([1: 3: length(x)]);
subplot(2,1,1)
stem(n, x(1:50)); axis([0 50 -1.2 1.2]);
title(’Input Sequence’);
xlabel(’Time index n’);
ylabel(’Amplitude’);
subplot(2,1,2)
stem(n, y); axis([0 50 -1.2 1.2]);
title(’Output Sequence’);
xlabel(’Time index n’);
ylabel(’Amplitude’);
Program illustrates the use of the M-function interp in the design and implementation
of an interpolator with an integer-valued interpolation factor L. interp designs and
uses a lowpass interpolation filter with a stopband edge satisfying Eq. (10.6).
% Program
% Illustration of Interpolation Process
%
clf;
L = input(’Up-sampling factor = ’);
% Generate the input sequence
n = 0:49;
x = sin(2*pi*0.043*n) + sin(2*pi*0.031*n);
% Generate the interpolated output sequence
y = interp(x,L);
% Plot the input and the output sequences
subplot(2,1,1);
stem(n,x(1:50));
title(’Input Sequence’);
xlabel(’Time index n’); ylabel(’Amplitude’);
subplot(2,1,2);
m = 0:(50*L)-1;
stem(m,y(1:50*L));
title(’Output Sequence’);
xlabel(’Time index n’); ylabel(’Amplitude’);
Program to illustrates the use of the M-function resample in the design and implementation of an interpolator with a fractional-rate interpolation factor L/M. resample designs and uses a lowpass interpolation filter with a stopband edge satisfying
% Program
% Illustration of Sampling Rate Alteration by
% a Ratio of Two Integers
%
clf;
L = input(’Up-sampling factor = ’);
M = input(’Down-sampling factor = ’);
n = 0:29;
x = sin(2*pi*0.43*n) + sin(2*pi*0.31*n);
y = resample(x,L,M);
subplot(2,1,1);
stem(n,x(1:30));axis([0 29 -2.2 2.2]);
title(’Input Sequence’);
xlabel(’Time index n’); ylabel(’Amplitude’);
subplot(2,1,2);
m = 0:(30*L/M)-1;
stem(m,y(1:30*L/M));axis([0 (30*L/M)-1 -2.2 2.2]);
title(’Output Sequence’);
xlabel(’Time index n’); ylabel(’Amplitude’);
0 comments:
Post a Comment