Challenge

Project - Data Handling and Interpolation

%This example shows how interpolation linear and spline can be created
%using a set of values

x=xlsread('VI','A2:A25');%read data V from excel file VI.xlsx and storing it in 'x' variable
y=xlsread('VI','B2:B25');%read data I from excel file VI.xlxx and storing it in 'y' variable
xq1=[-17.3:0.1:0.9];%interpolation data
yq1=interp1(x,y,xq1);%interpolating using linear interpolation method
yq2=interp1(x,y,xq1,'spline');%interpolating using spline interpolation method
figure(1);
plot(xq1,yq1,'--r','linewidth',0.5); %plotting the graph of linear interpolation
title('Linear Interpolation using VI data');
xlabel('V data');
ylabel('I data');
legend('Data');
print('laboratoryexperiment1','-dpdf');%saving the graph in pdf format
figure(2);
plot(xq1,yq2,':g','linewidth',2);%plotting the graph of spline interpolation
title('Spline Interpolation using VI data');
xlabel('V data');
ylabel('I data');
legend('Data');
print('laboratoryexperiment2','-dpdf');%saving the graph in pdf format
figure(3);
plot(x,y);% plot of a graph without interpolation
xlabel('V data');
ylabel('I data');
title(' VI data');
legend('Data');
print('laboratoryexperiment3','-dpdf');%saving the graph in pdf format
fileID=fopen('VI2.txt','w');% creating a text file 'VI2.txt'
fprintf(fileID,'%f\n', xq1 ,yq1 ,yq2);% print the interpolated x data and y data value in text file
fclose(fileID);%closing the text file

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.