Project - Data Handling and Interpolation
clc %to clear command window
[num,text,raw]=xlsread('VI','Sheet1','A1:B24'); %to read from given excel file
V=num(:,1); %to assign Voltage values
I=num(:,2); %to assign Current values
range=[-17.3:0.1:0.9]; %given Interploation range in question
A=interp1(V,I,range); %Linear interpolation code
B=interp1(V,I,range,'spline'); %Spline interpolation code
figure(1); %to plot figure
plot(V,I,'o',range,A,':'); % linear interpolation plot
title('Linear Interpolation') ; % to give title to the plot
xlabel('Voltage'); % to label x dimension
ylabel('Current'); % to label y dimension
axis([-18 2 -30 10]); % to limit the axis values of x,y
figure(2); %to plot figure
plot(V,I,'o',range,B,':'); % spline interpolation plot
title('Spline Interpolation') % to give title to the plot
xlabel('Voltage'); % to label x dimension
ylabel('Current'); % to label y dimension
axis([-18 2 -30 10]); % to limit the axis values of x,y
filename = fopen('project_matlab.txt','w'); %open file and provide write access
fprintf(filename,'%d \n',V,I,range,A,B); % "%d" is for datatype and \n is for line space between values
fclose(filename); % to close the file