Project - Data Handling and Interpolation
clc
% reading an Excel file
VA=xlsread('VI.xlsx','sheet1','A1:B12');
% readind voltage data
V=VA(:,1);
% reading current data
A=VA(:,2);
figure(1);
plot(V,A,'m--'),title('normal graph'),...
xlabel('voltage'),ylabel('current')
% interpolation
t=-17.3:0.1:0.9;
y=interp1(V,A,t,"spline");
figure(2);
% plotting V-I data after interpolation
plot(V,A,'O',t,y),title('Interpolation'),...
xlabel('voltage'),ylabel('current')
% reading given voltage values
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];
% current values for the given voltage vector
II=spline(V,A,VV);
% writing current values to a text file named as currents
fid=fopen('C:\Users\91934\OneDrive\Desktop\currents.txt','w');
fprintf(fid,'%f\n',II);
fclose(fid);