Project - Data Handling and Interpolation
%this project reads data from excel sheet do ainterpolation of the
%requied range of data
v=xlsread('C:\Users\91949\Downloads\VI.xlsx',1,'A2:A25');
%reading the values of volatge and storing them into vector V.
i=xlsread('C:\Users\91949\Downloads\VI.xlsx',1,'B2:B25');
%reading the values of volatge and storing them into vector i.
plot(v,i,'o'); %plotting V VS I plot
hold on; % plotting 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 volatges 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='calculating current from given data'; %title of text file
v='voltage(volt)'; %labeling the coloums of test file
i='current(mamp)';
fid = fopen ('mbproject.txt','w'); %creating test 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;
xlabel(' volatge V(volt)'); %labelling the plot
ylabel('current I(mamps)');
title('given voltage vs calculated current');