Project - Data Handling and Interpolation
Q1
clc;
% Data Interpolation of Voltage and Current
Data=xlsread('VI.xlsx'); % First read the data from xlsx file
V=Data(:,1); % Define voltage data
I=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,I,xq);
subplot(211)
plot(V,I,'r*',xq,xq1,'b-');grid on; % Linear interpolation
title('Linear Interpolation');
xlabel('Voltage(v)');
ylabel('Current(I)');
% here we start spline interpolation of data
xq2=interp1(V,I,xq,'spline');
subplot(212)
plot(V,I,'r*',xq,xq2,'g-'); % spline interpolation
grid on;
title('spline Interpolation');
xlabel('Voltage(V)');
ylabel('current(I)');
z=[V I];
fileID=fopen('Interpolation_Data.txt','w'); % open interpolation.txt file
fprintf(fileID,'%6s %12s\n','V','I'); % print file V & I
fprintf(fileID,'%6.2s %12.4s\n',z);
fclose(fileID); % close the file
Ans :
