Beruflich Dokumente
Kultur Dokumente
x=0:1:100;
y = sin(0.1*pi*x);
y1= decimate(y,2);
% decimation of y by a factor 2
y2= decimate(y,4);
% decimation of y by a factor 4
subplot(311)
stem(y(1:length(y)))
ylabel('original signal')
grid
subplot(312)
stem(y1(1:length(y1)))
ylabel('decimated by 2')
grid
subplot(313)
stem(y2(1:length(y2)))
xlabel('Time')
ylabel('decimated by 4')
grid
Example2: Repeat the above example with resample function.
x=0:1:100;
y = sin(0.1*pi*x);
y1= resample(y,1,2);
% sampling rate reduction by a factor of
2
y2= resample(y,1,4);
% sampling rate reduction by a factor of
4.
subplot(311)
stem(y(1:length(y)))
ylabel('original signal')
grid
subplot(312)
stem(y1(1:length(y1)))
ylabel('decimated by 2')
grid
subplot(313)
stem(y2(1:length(y2)))
xlabel('Time')
ylabel('decimated by 4')
grid
Example 3: Consider the signal of example 1. Interpolate the signal by a factor of 2 and
4 using interp function.
Solution.
x=0:1:100;
y = sin(0.1*pi*x);
y1= interp(y,2);
y2= interp(y,4);
subplot(311)
stem(y(1:length(y)))
ylabel('original signal')
grid
subplot(312)
stem(y1(1:length(y1)))
ylabel('interpolated by 2')
grid
subplot(313)
stem(y2(1:length(y2)))
xlabel('Time')
ylabel('interpolated by 4')
grid