Project - Data Handling and Interpolation
1.
A=xlsread('VI');
v=A(:,1);
i=A(:,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','southeast');
grid on;
figure(2)
plot(v,i,'s',xq,yq2,'m: .');
title('Spline interpolation');
xlabel('Voltage [V]');
ylabel('Current [I]');
legend('Actual value','Interpolated value','Location','southeast');
grid on;
val=fopen('vi.txt','w');
fprintf(val,' Voltage Current\n');
fprintf(val,'%4.3f %5.3f\n',xq,yq2);
savefig(1,'vilinear.fig');
savefig(2,'vispline.fig');
fclose(val);