Project - Data Handling and Interpolation
% This project reads data from excel sheet and do a interpolation of the
% requied range of data
V=xlsread('C:\Users\deves\Downloads\VI.xlsx',1,'A2:A25');
% Reading the values of voltage and storing them into vector V.
I=xlsread('C:\Users\deves\Downloads\VI.xlsx',1,'B2:B25');
% Reading the values of current and storing them into vector I.
plot(V,I,'o'); % plotting V Vs I plot
hold on; % holding plot for overlapping
Vh=[-17.3:0.1:0.9]; % Range of interpolation.
Ih=spline(V,I,Vh);
plot(Vh,Ih,'r--'); % plotting interpolated Vh Vs Ih curve.
grid; %setting up the grid
xlabel(' Voltage V(Volt)');%labelling the plot
ylabel('Current I(mAmp)');
title('Interpolated V-I Curve');
legend('Given data plot','Interpolated data plot');
hold off;
%Computing the current from given values of voltages and storing them in a
%text file
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];
% loading V as per given in the question
II=pchip(V,I,VV); % calculating current using pchip interpolation
F=[VV;II];
name='Calulating Current from given data'; % title of text file
v='Voltage(Volt)'; %labeling the coloumns of text file
i='Current(mAmp)';
fid = fopen('mbproject.txt','w'); %creating text file
fprintf(fid,'%s\n\n',name);
fprintf(fid,'%s %s\n',v,i);
fprintf(fid,'%f %f\n',F);
fclose(fid);
figure(2)
plot(VV,II,'m'); grid; %l plotting the plot in figure2
xlabel(' Voltage V(Volt)');%labelling the plot
ylabel('Current I(mAmp)');
title('Given Voltage Vs calculated current');
outputs

for calculating current from given data

