Atif Javed
Atif Javed

Reputation: 27

how to make interpolation and decimation vector length equal

I am trying to implement interpolation and decimation without using build in functions of MATLAB for this purpose i follow the following sequence

upsampling-> filter-> handle fir filter delay

these three steps known as interpolation

filter-> handle fir filter delay-> downsample
these three steps known as Decimation

In the above processing after handling group delay my overall symbols are reduced that create a problem to recover the same data that is the input of interpolation So what should i do to handle this problem.

My code is written below

idata=ones(1,100); %input symbols 100
nfilt=30;
upfac = 10;
alpha = 0.5;

xr = upsample(idata,upfac); %upconverted symbols which is 1000
h1 = intfilt(upfac,2,alpha);
y = filter(h1,1,xr);
delay = mean(grpdelay(h1));
y(1:delay) = [];            %filter delay discarded 19 symbols are remaining symbols are 981

[B,A]=fir1(30,1/10);

dec_filter=filter(B,A,y);  %down sample filter symbols are still 981
delay = mean(grpdelay(B));
dec_filter(1:delay) = [];  %delay is 15 and after handling delay symbols reduced to 966
dec=downsample(dec_filter,upfac); %after down sample remaining symbols are 96  

Upvotes: 1

Views: 467

Answers (1)

Tommaso Belluzzo
Tommaso Belluzzo

Reputation: 23685

You can avoid performing all those calculations manually by using the decimate function. Given your upsampled data, all you have to do is to execute the following code:

upfac = 10;
nfilt = 30;

idata = ones(1,100);
xr = upsample(idata,upfac);
dec = decimate(xr,upfac,nfilt,'fir');

Upvotes: 1

Related Questions