Interpolation in MATLAB
Last Updated :
16 Dec, 2022
Upsampling can be defined as a process that comprises adding zero-valued samples in between existing original samples in order to increase the sampling rate. Upsampling is also called zero-stuffing.
Interpolation:
Upsampling with Filtering is called Interpolation. Upsampling adds zero-valued samples and filtering replaces the zero-valued samples inserted by upsamplers with approximate non-zero values using some type of filtering.
Example:
Matlab
clc;Â
clear all;Â
fs=input( 'enter sampling frequency' );Â
f=input( 'enter frequency of signal' );Â
L=input( 'enter interpolation factor' );Â
t=0:1/fs:1;Â
x=sin(2*pi*f*t);Â
N=length(x);Â
n=0:N-1;Â
m=0:(N*L)-1;Â
x1=zeros(1,L*N);Â
j=1:L:N*L;Â
x1(j)=x;Â
f1=fir1(34,0.48, 'low' );Â
output=2*filtfilt(f1,1,x1);Â
y=interp(x,L);Â
subplot(3,1,1);Â
stem(n,x);Â
xlabel( 'samples' );Â
ylabel( 'amplitude' );Â
title( 'Input signal' );Â
subplot(3,1,2);Â
stem(m,output);Â
axis ([0 200 -1 1]);Â
xlabel( 'samples' );Â
ylabel( 'amplitude' );Â
title( 'Interpolated signal' );Â
subplot(3,1,3);Â
stem(m,y);Â
axis ([0 200 -1 1]);Â
xlabel( 'samples' );Â
ylabel( 'amplitude' );Â
title( 'Interpolated signal using inbuilt command' );
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...