Project - Data Handling and Interpolation
%%Interpolation
clc
voltage_current=xlsread('VI.xlsx'); %%To read excel file of VI experimental data
voltage=voltage_current(:,1); %%sorting the voltage value
current=voltage_current(:,2); %%sorting the current value
range=[-17.3:0.1:0.9];%% to create range of values
VI_inter= interp1(voltage,current,range,"spline"); %%to create interpolation of values
plot(voltage,current,'o',range,VI_inter,':.');%%To plot experimental and interpolated data
xlabel('voltage(v)')%%x-axis
ylabel('current(A)')%%y-axis
V_V =[-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]; %%creating voltage vector for writing it as text file
VI = interp1(voltage,current,VV,"spline"); %%interpolating the current value
legend('Experimental','interpolated'); %%naming of experimental and interpolated data
fid=fopen('voltage_current_characteristics.txt','w'); %%to open a text file of name voltage_current_characteristics.txt to write the datas
for i = 1:length(V_V)
fprintf(fid,'%.3f %.3f\n',V_V(i),VI(i));% storing value of variables in file
end
fclose(fid);
