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.
clc;clear all;close all
M=readmatrix('VI.xlsx')
V=M(:,1); %create an voltage for xlsx fill
I=M(:,2); %create an current for xlsx fill
x=-17.3:0.1:0.9; % missing Voltage Points
I_interp1=interp1(V,I,x,'linear'); %use of interpolation in linear
figure(1)
plot(V,I,x,I_interp1,'g*');
grid on;
xlabel('Voltage');ylabel('Current');title('Linear Interpolatiom');
I_interp2=interp1(V,I,x,'spline'); %use of interpolation in spline
figure(2)
plot(V,I,'r',x,I_interp2,'g*')
grid on
xlabel('Voltage');ylabel('Current');title('Spline Interpolatiom');
y=[x;I_interp1];
fileid=fopen('voltage_current.txt','w');
fprintf(fileid,'%d %f\n', y);
fclose(fileid);
