Project - Data Handling and Interpolation
%PROJECT 1
clc;
clear;
A = xlsread('VI.xlsx');;%to read xl file
v = A(:,1);%for calling first colum elements
i = A(:,2);%for calling 2nd colum elements
v1 = -17.3:0.1:0.9;
ib1 = interp1(v,i,v1);
figure(1)
plot(v,i,'m:.',v1,ib1,'g--');
title('linear interpolation');xlabel('voltage');ylabel('current');
legend('original','interpolated');
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];
i2=interp1(v,i,vv);
figure(2)
plot(vv,i2,'g');
title('interpolation');xlabel('voltage');ylabel('current');
vvi2=[vv;i2];
fid = fopen('voltage_current.txt','w');
fprintf(fid,'%65s %10s\n','voltage','current');
fprintf(fid,'%5f %10f\n',vvi2);
fclose(fid);