Project - Data Handling and Interpolation
Project - Data Handling and Interpolation
code: (NOTE: I have taken the voltage and current values accoring to ohms law i.e. V=IR and Ris taken as 5ohms. so the graph will be linear in nature)
v = xlsread('VI.xls','A1:A22'); %loading the data of voltage from excel sheet i.e VI.xls
i = xlsread('VI.xls','B1:B22'); %loading the data of current from excel sheet i.e VI.xls
v1 = (-17.3:0.1:0.9); %declearing the v1 as they mentioned in the question for interpolation
i1 = interp1(v,i,v1,'spline'); %creating i1 i.e by using interpolation function by v1 and spline is used for smooth graph
plot(v1,i1,'b-');grid;hold; %ploting the graph by using inetrpolated current values i.e., i1 vs voltage range i.e, v1
xlabel('Voltage(v)');ylabel('Current(A)');title('Interpolated data of V and I'); % declaring the naming for x-axis,y-axis and title for the graph
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]; %given Voltage(VV) values for finding the corresponding Current values
i2 = interp1(v,i,VV);%creating i2 i.e by using interpolation function by VV
x =VV';%invering the VV' values for a matrix form i.e by a single coloumn which helps in easy understing and writing the data to a text file
y = i2'; %invering the i2' values for a matrix form i.e by a single coloumn which helps in easy understing and writing the data to a text file
data = [x y]; %creating the matrix i.e data, which contains 1st coloumn of Voltage i.e., VV and 2nd coloumn of Current i.e., i2
%NOTE : Here i created the voltage and current as a matrix form containing 1st coloumn as voltage i.e VV and 2nd coloumn as Current i.e i2 because for writing the current values corresponding voltage values (VV) side byside
Header =["VV" "Current"]; %creating the headers for text file
writematrix(Header,'Interpolated_VI_data.txt','Delimiter','tab'); %writing the header data to text file
writematrix(data,'Interpolated_VI_data.txt','Delimiter','tab','WriteMode','append');%writing the matrix i.e data to text file

