Sample Rate Altering Blocks

by

 

The folder contains 2 codes: 1)to implement an upsampler 2)to implement a downsampler

[y ny]=upsampler(x,n,L)
%*************************************************************************%
%A code for the Upsampler%
%Author: Yashwant Marathe%
%Date:20-12-2010%

function [y ny]=upsampler(x,n,L)
%x is a sequence over indices specified by vector n,L is the upsampling factor.

ny=L*min(n):L*max(n);
%generates a vector over the expected indices of output

param=ny/L;
%generates a parameter vector,which decides where input samples will be appended in a longer output.

samp=fix(param)==param;
%The input samples will appear in output only where the corresponding entry in samp vector is 1.

y=zeros(1,length(ny));
%generates the zero output vector

y(samp==1)=x;
%appends input samples in the outut vector

end

%*************************************************************************%

Contact us