Project - Data Handling and Interpolation
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.
Key Highlights:
- Graphical solutions are more visual and appealing
- Interpolation of data
- Read excel file
- Write to text file
Deliverables:
- Find missing data and save it in text
- Interpolate the data set
- Save your program and attach the same.
- Save txt file and upload in attachment
clear;
clc;
% interpolation of voltage and currentdata
% reading excel file data
D =readmatrix('VI.xlsx');
v=D(:,1); % vpltage data seperating
i=D(:,2); % current data seperating
xq=-17,3:0.1:0.9; % given interpolation range
yq1=interp1(v,i,xq); % linear interpolation
yq2=interp1(v,i,xq,'spline'); % spline interpolation
% liner interpolation plotting
figure(1)
plot(v,i,'S',xq,yq1,':');
title('linear interpolation')
xlabel('voltage (V)');
ylabel('current (I)');
legend('Actual value','interpolated value','location','northeast');
grid on;
% spline interpolation plotting
figure(2)
plot(v,i,'s',xq,yq2,'b:.');
title('SPLINE INTERPOLATION');
xlabel('voltage(V)');
ylabel('current(I)');
legend('Actual value','interpolated value','location','northeast');
grid on;
% saving the interpolation data into text file
% opening text file
vol_cu=fopen('VI._output.txt','w');
fprintf(vol_cu,'voltage current\n');
%writing voltage & current valve
fprintf(vol_cu,'%4.3f %5.3f\n',xq,yq2);
% saving linear interpolation graph
savefig(1,'vilinear.fig');
%saving spline interpolation graph
savefig(2,'vispline.fig');
fclose(vol_cu);

