All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Project Data Handling and Interpolation AIM: In a laboratory experiment, data of voltage and current has been recorded and the same is attached in…
Sridharan p
updated on 18 Nov 2022
Project
Data Handling and Interpolation
AIM:
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:
Deliverables:
Answer:
Interpolation is the process of creating a new value based on the values already present in a set of data. The act of inserting or interjecting a middle value between two other values is another way to put it.
Interpolation is the process of determining a function's value in data science or mathematics based on the values of other datapoints in a given sequence. The known x values may range from x0 to xn, and this function may be written as f(x).
To determine and display interpolated data for provided data, use the interp1 function.
Read the data and store it in the variable x using the xlsread function.
MATLAB CODE:
clear;
clc;
% interpolation of voltage and current data
% read data excel file data
D=xlsread('VI.xlsx');
v=D(:,1); % voltage data seperating
i=D(:,2); % current data seperating
xq=[-17.3:0.1:0.9]; % Given interpolation range
% linear interpolation
yq1=interp1(v,i,xq);
% spline interpolation
yq2=interp1(v,i,xq,'spline');
% Linear interpolation plot
figure(1)
plot(v,i,'s',xq,yq1,': .');
title('Linear Interpolation');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;
% spline interpolation plot
figure(2)
plot(v,i,'s',xq,yq2,'b: .');
title('SPLINE INTERPOLATION');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;
% saving the interpolation data into text file.txt
%opening the txt file
Text_file=fopen('VI_output.txt','w');
fprintf(Text_file,' Voltage Current\n');
%writing voltage & current value
fprintf(Text_file,'%4.3f %5.3f\n',xq,yq2);
%saving linear interpolation graph
savefig(1,'vilinear.fig');
%saving spline interpolation graph
savefig(2,'vispline.fig');
fclose(Text_file);
RESULT: OUTPUT
THE TEXT IS CREATED AND SAVED:
Workspace:
Conclusion:
We successfully do the interpolation in the range of -17.3:0.1:0.9, according to the results. create an interactive plot for the interpolated data as well as save it in a text file.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.