Project - Data Handling and Interpolation
First project
%Data of laboratory experiments of voltage and current
%Importing data from excell
laboratory_experiment=xlsread("VI.xlsx");
%assigning values to inputs
V = laboratory_experiment(:,1);
I = laboratory_experiment(:,2);
%Plotting the values V and I
plot(V,I);grid;
%Assigning range
xq = -17.3:0.1:0.9;
%Solving using interpolation
y = interp1(V,I,xq,'spline');
figure(1);
plot(V,I,'o',xq,y,':');
grid;hold;
title('laboratory experiment');
% compute the current values for given voltages below
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];
%Solving using interpolation to compute
U = interp1(V,I,VV);
D = [VV U]
%Storing the results in text file
fid = fopen('project.txt','w');
fprintf(fid,'%6s %12s\n','VV','U');
fprintf(fid,'%6.2f %12.2f\n',D);
fclose(fid);
xlabel('Voltage(v)');ylabel('Current(I)');
legend('V and I');

