Challenge

Project - Data Handling and Interpolation

clc
D=xlsread('interpolation') %reading excel file data
v=D(:,1);
i=D(:,2);
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 ploting
plot(v,i,'s',xq,yq1,':*');
xlabel('voltage(v)');
ylabel('current(I)');
legend('actual value','interpolated value','location','northeast');
grid on;
figure(2)

%ploting spline interpolation
plot(v,i,'s',xq,yq2,':.');
xlabel('voltage');
ylabel('current');
legend('actual value','interpolated value','location','northeast');
title('spline interpolation');
grid on;

% saving the interpolation datainto text file
vol_cu=fopen('VI_output.txt','w'); %opening the text file
fprintf(vol_cu,'voltage current\n');
fprintf(vol_cu,'%4.3f %5.3f\n' ,xq,yq2); %writing voltage and current

%saving spline interpolationgraph
savefig(1,'vilinear.fig');
savefig(2,'vispline.fig');
fclose(vol_cu);

mscript explanation

The given input excel data file is read by using the comand "xlsread",

Input value voltage and current are seperated by (:,1),(:2) respetively.

Interpolation range is given in question [-17.3:0.1:0.9]

Interpolation is done by using syntax-interp1() for voltage and current data.

Spline interpolation is done by syntax-interp1().

Ploting the both interpolation data in graph with labeling x&y.

And give titel to both figure (1) & (2)

For saving the output data and plot a text file is created with the name'vi_output.txt' for this use command

f open()

And interpolation data is print by command fprint()

Plot are save by command savefig()

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.