Project - Data Handling and Interpolation
Project :
In a laboratory experiment, data of voltage and current has been recorded and the same is attached in an excel file ( Click on this link VI.xlsx ). Read the excel file in the Matlab program and perform the interpolation in the range of -17.3:0.1:0.9. Generate the interactive plot for the interpolated data and store them in a text file
Program;
% Data Interpolation of volage and current
Data=xlsread('VI.xlsx');% first read the data from xlsx file
V=Data(:,1); % Define voltage data
A=Data(:,2); % define current data
xq=(-17.3:0.1:0.9); % Range of interpolation
% here we start the linear interpolation of data
xq1=interp1(V,A,xq);
subplot(211)
plot(V,A,'r*',xq,xq1,'b-');grid; % linear interpolation
title('Linear Interpolation');
xlabel('voltage(v)');
ylabel('current(A)');
% here we start spline interpolation of data
xq2=interp1(V,A,xq,'spline');
subplot(212)
plot(V,A,'r*',xq,xq2,'g-');
grid; % spline interpolation
title('spline Interpolation');
xlabel('voltage(V)');
ylabel('current(A)');
Z= [V A];
fileID=fopen('Interpolation_Data.txt','w'); % open interpolation.txt file
fprintf(fileID,'%6s %12s\n','V','A'); % save the values of V and A in file
fprintf(fileID,'%6.2s %12.4s \n',Z);
fclose(fileID); % close the file