Project - Data Handling and Interpolation
% V vs I
A=xlsread('VI.xlsx') %read xlsx file
V=A(:,1) % COLUMN A for VOLTAGE
I=A(:,2) % A(row,col) COLUMN B for CURRENT
V1=[-17.3:0.1:0.9] %interpolation range
Ib1=interp1(V,I,V1) %linear interpolation
Ib2=interp1(V,I,V1,'spline') %spline interpolation
figure(1)
plot(V,I,'o',V1,Ib1,':.') % plot linear interpolation
grid
title('linear interpolation')
figure(2)
plot(V,I,'o',V1,Ib2,':.') % plot spline interpolation
grid
title('spline interpolation')
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] % new voltage range
I2=interp1(V,I,VV) %linear interpolation for find value of current
figure(3)
plot(VV,I2,'o--') % plot linear interpolation for new voltage and current value
grid
VVI2=[VV;I2] % save value in matrix
fid=fopen('I.txt','w') % Write to text file
fprintf(fid,'%6s %12s\n','Voltage','Current'); % title for voltage and current
fprintf(fid,'%6.2f %12.8f\n',VVI2); % save data for voltage and current
fclose(fid);