0% found this document useful (0 votes)
305 views

Decimation and Interpolation in Matlab

This MATLAB code allows a user to enter a numeric sequence and then either decimate or interpolate the sequence. It takes the input sequence, decimates it by removing elements at a specified factor or interpolates it by inserting a specified number of zeros between each element. The resulting decimated or interpolated sequence is then displayed.

Uploaded by

monicaedu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
305 views

Decimation and Interpolation in Matlab

This MATLAB code allows a user to enter a numeric sequence and then either decimate or interpolate the sequence. It takes the input sequence, decimates it by removing elements at a specified factor or interpolates it by inserting a specified number of zeros between each element. The resulting decimated or interpolated sequence is then displayed.

Uploaded by

monicaedu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

clc; clear all; close all;

x=input('Enter sequence:');
N=length(x);
ch=input('1. decimation 2.interpolation...enter choice:');
switch(ch)
case 1
n=input('Enter decimation factor:');
m=ceil(N/n);
y=zeros(1,m);
k=1;
for i=1:m
if(k<=N)
y(1,i)=x(1,k);
end
k=k+n;
end
disp(y);
case 2
n=input('Enter no. of interpolated zeros:');
N1=N+(n-1)*N;
y=zeros(1,N1);
i=1; k=1;
while i<=N1
j=1;
while(j<n);
y(1,i)=0;
i=i+1;j=j+1;
end
if(k<=N)
y(1,i)=x(1,k);
end
k=k+1; i=i+1;
end
disp(y);
end

You might also like