%% Resample a Sinusoid
% Generate 60 samples of a sinusoid and resample it at 3/2 the original rate. Display the original and resampled signals.

tx = 0:6:360-3;
x = sin(2*pi*tx/120);

ty = 0:4:360-2;
[y,by] = resample(x,3,2);

plot(tx,x,'+-',ty,y,'o:')
legend('original','resampled')

%
% Plot the frequency response of the anti-aliasing filter.

freqz(by)

%
% Resample the signal at 2/3 the original rate. Display the original signal and its resampling.

tz = 0:9:360-9;
[z,bz] = resample(x,2,3);

plot(tx,x,'+-',tz,z,'o:')
legend('original','resampled')

%
% Plot the impulse response of the new lowpass filter.

impz(bz)

% Copyright 2012 The MathWorks, Inc.