Project - Data Handling and Interpolation
1.In a laboratory experiment, data of voltage and current has been recorded and the same is attached in an excel file ( Click on this link VI.xlsx ). Read the excel file in the Matlab program and perform the interpolation in the range of -17.3:0.1:0.9. Generate the interactive plot for the interpolated data and store them in a text file.
Ans-
The program is as follow
D=xlsread('VI.xlsx');
v=D(:,1);
i=D(:,2);
xq=-17.3:0.1:0.9;
yq1=interp1(v,i,xq);
yq2=interp1(v,i,xq,'spline');
figure(1)
plot(v,i,'s',xq,yq1,': .');
title('Linear Interpolation');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;
figure(2)
plot(v,i,'s',xq,yq2,'b: .');
title('SPLINE INTERPOLATION');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;
vol_cu=fopen('VI_output.txt','w');
fprintf(vol_cu,' Voltage Current\n');
fprintf(vol_cu,'%4.3f %5.3f\n',xq,yq2);
savefig(1,'vilinear.fig');
savefig(2,'vispline.fig');
fclose(vol_cu);
The output of the program is as below


