Interpolation in MATLAB Last Updated : 16 Dec, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. y(n) = { x(n/l), n=0,+l or -l.+2l or -2l,+3l or -3l 0, Otherwise } Example: Matlab % MATLAB code for interpolation %clc is used to clear the command window clc; clear all; % taking sampling frequency as input % and storing in fs variable fs=input('enter sampling frequency'); % taking frequency of the signal as input and storing in f f=input('enter frequency of signal'); % taking interpolation factor I as input and storing it in L L=input('enter interpolation factor'); %defining time-axis t=0:1/fs:1; % generating a sinusoidal signal with % a given frequency and time-axis tf x=sin(2*pi*f*t); % storing length of axis x in N N=length(x); % taking another axis ranging from 0 to N-1 n=0:N-1; % taking another axis ranging from 0 to N*L-1 m=0:(N*L)-1; % creating zeros in axis of length L*N % and storing it in x1 x1=zeros(1,L*N); % taking another axis with a interpolation factor % L from 0 to increasing with a factor L and upto N*L j=1:L:N*L; % taking j values into x1 from x x1(j)=x; % creating a window-based finite inpulse response filter design % Syntax: b = fir1(n,Wn,'ftype') % n is number of samples ranging from 0 % to N-1, Wn is normalized frequency ranging from % 0 to 1,'ftype' specifies a filter type f1=fir1(34,0.48,'low'); % filtfilt command provides zero-phase digital filtering by % processing input data x in both forward and reverse directions % Syntax: y=filtfilt(b,a,x); % b,a specifies the filter order % x is input data output=2*filtfilt(f1,1,x1); % Syntax: y=interp(x,r); % the above command specifies increasing the sampling % rate of signal x by a factor of r. y=interp(x,L); % subplot command in MATLAB allows you to insert % multiple plots in a grid where all % plots are specified in same grid subplot(3,1,1); % stem command is to plot discrete signal stem(n,x); % xlabel shows name of x axis in a plot xlabel('samples'); % ylabel shows name of y axis in a plot ylabel('amplitude'); % title is shown at the top of figure % title is usually used to specify the name % of your figure title('Input signal'); subplot(3,1,2); stem(m,output); % axis command specifies the limit of current axis 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: Comment More infoAdvertise with us Next Article 2D Array Interpolation in MATLAB A abdulmalikpasha Follow Improve Article Tags : Software Engineering Similar Reads Integration in MATLAB Integration is defined as the process of finding the anti derivative of a function. It is used to calculate area, volume, displacement, and many more. In this article, we will see how to perform integration on expressions in MATLAB. There are two types of Integration: Indefinite integral: Let f(x) b 3 min read Linear Interpolation in MATLAB Interpolation is a numerical method of finding new data points by finding a pattern in a given set of discrete data points. There are various types and methods of interpolation in the field of Numerical Analysis such as linear interpolation, cubic interpolation, spline interpolation, etc. The key p 3 min read 2D Array Interpolation in MATLAB In this article, we are going to discuss "2D Array Interpolation" in MATLAB with the help of two linspace() and interp2() functions. Functions Usedlinspace( ) The linspace() function is used for the generation linearly spaced vector. Syntax: linspace(a, b) linspace(a, b, n) Here, linspace(a, b) is 4 min read 3D Array Interpolation MATLAB Interpolation is a method of finding the value of queried data points based on the trend created by existing data points. MATLAB provides many options to perform interpolation on data of N-dimensions. In this article, we shall discuss how to interpolate data in a 3D array with the help of some exam 3 min read Cubic Spline Data Interpolation in MATLAB Cubic spline interpolation is a type of interpolation in which data of degree 3 or less is interpolated. Refer to this article to understand the proper theoretical concept of Cubic Spline Interpolation. Now we will look at how to perform cubic spline interpolation in MATLAB.  MATLAB provides a simpl 1 min read Interpolation Functions in R In this article, we will be looking towards the approx() and the aproxfun() interpolation function with working examples in the R Programming language. Approx() and Approxfun() interpolation function These functions return a list of points that linearly interpolates given data points, or a function 5 min read Like