Project - Data Handling and Interpolation
Project :
In a laboratory experiment, data of voltage and current has been recorded and the same is attached in an excel file ( Click on this link VI.xlsx ). Read the excel file in the Matlab program and perform the interpolation in the range of -17.3:0.1:0.9. Generate the interactive plot for the interpolated data and store them in a text file.
Key Highlights:
- Graphical solutions are more visual and appealing
- Interpolation of data
- Read excel file
- Write to text file
- Deliverables:
- Find missing data and save it in text
- Interpolate the data set
- Save your program and attach the same.
- Save txt file and upload in attachment
AIM:
- In this project, we are reading the excel file into the MATLAB program.
- perform the interpolation in the range of -17.3:0.1:0.9
- Generate the interactive plot for the interpolated data and store them in a text file.
What is interpolation?
Interpolation is a method of fitting the data points to represent the value of a function. It has various applications in engineering and science, that are used to construct new data points within the range of a discrete data set of known data points or can be used for determining a formula of the function that will pass from the given set of points (x, y).
Types of interpolation methods are:
- Linear interpolation
- Nearest neighbor interpolation or Piecewise constant interpolation
- Polynomial interpolation
- Spline interpolation
- Mimetic interpolation
- Cubic Spline Interpolation
- Linear interpolation:

A linear interpolation is a form of interpolation, which involves the generation of new values based on an existing set of values. Linear interpolation is achieved by geometrically rendering a straight line between two adjacent points on a graph or plane. All points on the line other than the original two can be considered interpolated values.
Linear Interpolation Formula
The formula to calculate linear interpolation is:
Linear Interpolation(y) = y1+(x−x1) (y2−y1) (x2−x1) y1+(x−x1) (y2−y1) (x2−x1)
were,
- x1x1 and y1y1 are the first coordinates
- x2x2 and y2y2 are the second coordinates
- x is the point to perform the interpolation
- y is the interpolated value
- Nearest neighbor interpolation or Piecewise constant interpolation

Interpolation is the problem of approximating the value of a function for a non-given point in some space when given the value of that function in points around (neighboring) that point. The nearest neighbor algorithm selects the value of the nearest point and does not consider the values of neighboring points at all, yielding a piecewise-constant interpolant.
- Polynomial interpolation

Polynomial interpolation is a method of estimating values between known data points. When graphical data contains a gap, but data is available on either side of the gap or at a few specific points within the gap, an estimate of values within the gap can be made by interpolation.
- Spline interpolation

Spline interpolation similar to the Polynomial interpolation x’ uses low-degree polynomials in each of the intervals and chooses the polynomial pieces such that they fit smoothly together. The resulting function is called a spline.
- Mimetic interpolation
mimetic interpolation is a method for interpolating differential forms. In contrast to other interpolation methods, which estimate a field at a location given its values on neighboring points, mimetic interpolation estimates the field's k{\displaystyle k} Kk-form given the field's projection on neighboring grid elements. The grid elements can be grid points as well as cell edges or faces, depending on k=0,1,2, 3…{\displaystyle k=0,1,2,\cdots }.
Mimetic interpolation is particularly relevant in the context of vector and pseudo-vector fields as the method conserves line integrals and fluxes, respectively
- Cubic Spline Interpolation:

Cubic spline interpolation is a special case for Spline interpolation that is used very often to avoid the problem of Runge's phenomenon. This method gives an interpolating polynomial that is smoother and has smaller errors than some other interpolating polynomials such as Lagrange polynomial and Newton polynomial.
project answer:-
clear;
clc
%Interpolation of voltage and current data
%reading Excel file data
D=xlsread('VI');
V=D(:,1);%voltage data seperating
i=D(:,2);%current data seperating
xq = -17.3:0.1:0.9% given interpolation range
yq1=interp1(V,i,xq);%linear interpolation
yq2=interp1(V,i,xq,"spline");%spline interpolation
figure(1);
plot(V,i,'s',xq,yq1,':.'); %linear interpolation plotting
title('linear interpolation');
xlabel('volatge(v)');
ylabel('current(i)');
legend('Actual value', 'interpolated value', 'location', 'northeast');
grid on;
% spline interpolation plotting
figure(2);
plot(V,i,'s',xq,yq2,'b: .');
title('spline interpolation')
xlabel('volatge(v)');
ylabel('current(i)');
legend('Actual value', 'interpolated value', 'location', 'northeast');
grid on;
%saving the interpolation data into a text file
vol_cu=fopen('VI.output.txt','w');
fprintf(vol_cu,'voltage current\n');
% writing voltage and current value
fprintf(vol_cu,'%4.3f %5.5f\n',xq,yq2);
%savaing linear interpolation graph
savefig(1,'vilinear.fig');
%savaing spline interpolation graph
savefig(2,'vispline,fig');
fclose(vol_cu);
project screenshot:-

linear interpolation output:-

spline interpolation output:-

workspaceoutput:-
