Project - Data Handling and Interpolation
% following programs for reads the data from VI.xlsx file & does interpolation of needed data
V=xlsread('C:\Program Files\Matlab\R2015b\bin\VI',1,'A2:A25');
%It Reads the values of voltage and stores them in vector V.
I=xlsread('C:\Program Files\Matlab\R2015b\bin\VI.xlsx',1,'B2:B25');
% Reads the values of current and stores them in vector I.
plot(V,I,'*'); % plots V Vs I with asterisk
hold on; %hold the plot for overlapping
Vh= -17.3:0.1:0.9; %given Range of interpolation.
Ih=spline(V,I,Vh);
plot(Vh,Ih,'g-.'); % plots the interpolated Vh Vs Ih curve
grid; %grid setting
title('Interpolated V-I Curve');
legend('Given data plot','Interpolated data plot');
xlabel(' Voltage V(Volt)');%labelling the plot
ylabel('Current I(mAmp)');
hold off;
%for find the missing current from given data of voltage & store it into text file
V1=[-17.2000 -13 -11 -9 -6 -1 0.1100 0.2500 0.5000 0.6100 0.6600];
%Loads V as per given
I1=pchip(V,I,V1); % for calcualtion of current by use pchip interpolation
F=[V1;I1];
name='Calulated Current by given data'; %for the title of text file
V='Voltage (Volt)'; % for label the coloumns of output text file
I='Current (mAmp)';
fid = fopen('matlab_project.txt','w'); %It create the text file
fprintf(fid,'%s\n\n',name);
fprintf(fid,'%s %s\n',V,I);
fprintf(fid,'%f %f\n',F);
fclose(fid);
figure(2)
plot(V1,I1,'m');%plots in figure(2)
grid;
title('Given Voltage data Vs calculated current');%for title the plot
xlabel(' Voltage V(Volt)');%for label the x axis of plot
ylabel('Current I(mAmp)');%for label the y axis of the plot


