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.
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
Answer:-
% Reading the xlsx file
data = readmatrix('VI.xlsx');
% Reading data from first column of xlsx file
V=data(:,1);
% Reading data from first column of xlsx file
I=data(:,2);
%Given range
X=-17.3:0.1:0.9
%ploting given data points separately
plot(V,I,'r*')
grid;
legend('Given data points')
title('Given data points graph')
xlabel('V (Volt)')
ylabel('I(mAmp)')
% using interpolation command
%ploting Given range points separately
Y=interp1(V,I,X)
figure(2)
plot(Y,'g--')
grid;
legend('Given range points')
title('Given range points graph')
xlabel('V (Volt)')
ylabel('I(mAmp)')
%ploting given data points and given range points together
figure(3)
plot(V,I,'r*',X,Y,'g--')
grid;
legend('Given data points','Given range points')
title('complete curve using linear inertpolation')
xlabel('V (Volt)')
ylabel('I(mAmp)')
% Saving Text File
filename = fopen('Lab_data.txt','w');
fprintf(filename,'%8s %12s\n','V(volt)','I(Amp)');
fprintf(filename,'%f %f\n',Y);
fclose(filename);
