Project - Data Handling and Interpolation
Aim:
- Handling and Interpolating the Data
Objective :
- read the laboratory experimented data from the excel file.
- extract the data and store it in variables.
- Then interpolate them.
- Compute the current from the given voltage data.
- Store this computed data in the text file.
project_fileHandling.m file :
clc
clear
close all
%% reading data from excel
FileId = xlsread('VI.xlsx');
V = FileId(:,1);
I = FileId(:,2);
%% interpolation linear
Vq = -17.3:0.1:0.9 ;
Iq = interp1(V,I,Vq);
%% spline method Iq2
Iq2 = interp1(V,I,Vq,'spline');
%% computing current(Iq3) for the given VV voltage data
VV =[-17.2,-17.1,-13.8,-13.5,-13.0,-12.5,-11,-9,-5.76,-6,-1,0.11,0.25,0.5,0.61];
Iq3 = interp1(V,I,VV);
%% plotted the V Vs I
subplot(2,2,1);
plot(V,I,'o','LineWidth',2);
grid on
axis([-18 2 -30 5])
xlabel('voltage V Volt');
ylabel('Current I Ampere');
title('V vs I data')
subplot(2,2,2);
plot(V,I,'o',Vq,Iq,'r','LineWidth',2);
grid on
axis([-18 2 -30 5])
xlabel('voltage V Volt');
ylabel('Current I Ampere');
title('V vs I Linear Interpolation')
subplot(2,2,3);
plot(V,I,'o',Vq,Iq2,'g','LineWidth',2);
grid on
axis([-18 2 -30 5])
xlabel('voltage V Volt');
ylabel('Current I Ampere');
title('V vs I Spline Interpolation')
%% compute the current from the given voltage data And store it in the text File
f = fopen('voltageCurrentData.txt','w');
fprintf(f,'computing the current from given voltage data\n');
fprintf(f,'Voltage\t Current \n');
for i=1:length(VV)
fprintf(f,'%.4f \t %0.4f\n ',VV(i),Iq3(i));
end
fclose(f);
- Using the xlsread function read the data and store it in the variable called FileId.
- from that extracted the first column which is voltage data and stored as variable V
- also extracted the second column which is current data stored as variable C.
- Then we interpolated the curve by adding some range of data in function interp1 Iq.
- smooth the data by spline interpolation method Iq2.
- computing the current Iq3 for given VV data by adding that data interp function.
- then plotted V Vs I data, second V Vs I data with Linear interpolated curve, Third V Vs I data and spline interpolated curve.
- for storing the computing data, we first open the file in write mode using fopen function pointer called f.
- using the for loop we printed the data in the VoltageCurrentData.txt file.
- and closed file.
Result After running the above program :

text file data
