Project - Data Handling and Interpolation
Matlab program to perform the interpolation:
program:
file=xlsread('VI.xlsx'); % command to read the excel file
V=file(:,1); % column 1 of file
R=-17.3:0.1:0.9; % interpolation range
Z=interp1(V,I,R); % interpolation of V & I
plot(R,Z,'-.'); % command to plot V&I
grid on
xlabel('volt');
ylabel('Amp');
title('V vs I') %title for the plot
% following lines are used to save voltage and current values in a text file
text1=fopen('VIout.txt','w'); % command to create a text file as 'VIout.txt'
Vo=[-17.2 -13 -11 -9 -6 -1 0.11 0.25 0.5 0.61 0.66];
Io=interp1(V,I,Vo); %interpolation of V&I for every V0 value
N=[Vo Io];
fprintf(text1,'%6s%8s\n','Vo','Io'); % command to print the data of Vo & Io
fprintf(text1,'%6.2f%8.2f\n',N); % command to print the data of N
fclose(text1); % command to close the file
output:
>> Vo
Vo =
-17.2000 -13.0000 -11.0000 -9.0000 -6.0000 -1.0000 0.1100 0.2500 0.5000 0.6100 0.6600
>> Io
Io =
-26.0000 -2.5000 -1.6500 -1.1500 -0.7333 -0.1889 0 0 0.1700 1.6100 NaN
>>
% the text file and plot are attached below