Project - Data Handling and Interpolation
clc
close all
%for Reading the excel file in the Matlab program
ISA=readmatrix('Vi.xlsx');
disp(ISA)
%storing voltage and curren in V and I
V = ISA(:,1);
I = ISA(:,2);
%first plot for given data
figure(1)
plot(V,I,'g*');hold on;grid
title('given Data of voltage and current')
xlabel('Voltage (volt)')
ylabel('Current (mAmp)')
%interpolation for given range (-17.3:0.1:0.9)
x = (-17.3:0.1:0.9)
y = interp1(V,I,x)
%interpolation plot for range(-17.3:0.1:0.9)
figure(2)
plot(y,'r--');hold on;grid
title('interpolated Data of voltage and current')
xlabel('Voltage (volt)')
ylabel('Current (mAmp)')
%% Combined plot for both data
figure(3)
plot(V,I,'*r',x,y,'g--');;hold on;grid
title('given and interp Data of voltage and current')
xlabel('Voltage (volt)')
ylabel('Current (mAmp)')
%% saving file in text file
fileID = fopen('lab_data.txt','W');
fprintf(fileID,'%8s %10s\n','V(volt)','I(mAmp)');
fprintf(fileID,'%f %f\n',y);
fclose(fileID);