Project - Data Handling and Interpolation
% importing the data from the excel sheet1 to matlab-
% -into a variable ' data '
data = xlsread('VI.xlsx','Sheet1');
%ssigning values from column 1 of the excel file to V
V = data(:,1);
%ssigning values from column 2 of the excel file to I
I = data(:,2);
% importing the data from the excel sheet2 to a matlab which can be-
% -considered as missing data into a variable ' missing_data '
missing_data = xlsread('VI.xlsx','Sheet2');
plot(V,I,'b'); % plotting voltage vs current curve
xlabel('voltage(Volts)');
ylabel('current(Amps)');
title('current vs voltage curve');
grid on
% interpolation range according to problem statement
r = -17.3:0.1:0.9;
% performing the interpolation
inter_p = interp1(V,I,r,'spline');
figure(2)
% plotting the interpolated data in current vs voltage curve
plot(V,I,'bo',r, inter_p,'r');
xlabel('voltage(V)');
ylabel('current(I)');
title('current vs voltage curve');
hold on
% interpolating the missing data of sheet2 of the excel file
inter_p2 = interp1(V,I,missing_data,'spline');
plot(missing_data, inter_p2,'go'); %plotting the interpolated missing data
% green circles are the interpolated points of sheet 2
legend(' I vs V(sheet1)', 'interpolated curve(RANGE)','missing data points(sheet 2)');
grid on
% VV -> given in the problem statement
VV =[-17.2 -17.1 -13.8 -13.5 -13.0 -12.5 -11 -9 -5.76 -6 -1 0.11 0.25 0.5 0.61];
inter_p3 = interp1(V,I,VV,'spline');
% transpose is taken to represent column wise
z = [VV' inter_p3'];
a = [r' inter_p'];
% transpose not taken as as data are already column wise
b = [missing_data inter_p2];
% writing the interpolated data to a text file
% z,a,b are matrices having voltage and current values
writematrix(z,'Corrsponding Current Values VV')
writematrix(a,'Corrsponding Current Values RANGE')
writematrix(b,'Corrsponding Current Values sheet2')
% left side of the text file are Voltage values
% right side of the text file are Current values