Challenge

Project - Data Handling and Interpolation

% interpolation of voltage and current data
% reading excel file data
D=xlsread('VI');
v=D(:,1); % voltage data seperating
i=D(:,2); % current data seperating
xq=-17.3:0.1:0.9; % Given interpolation range
yq1=interp1(v,i,xq); % linear interpolation
yq2=interp1(v,i,xq,'spline'); % spline interpolation
% Linear interpolation plotting
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;
% spline interpolation plotting
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;
% saving the interpolation data into text file
%opening text file
vol_cu=fopen('VI_output.txt','w');
fprintf(vol_cu,' Voltage Current\n');
%writing voltage & current value
fprintf(vol_cu,'%4.3f %5.3f\n',xq,yq2);
%saving linear interpolation graph
savefig(1,'vilinear.fig');
%saving spline interpolation graph
savefig(2,'vispline.fig');
fclose(vol_cu);
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.