Project - Data Handling and Interpolation
Answer:
In this case, few datapoints lie outside teh domain of V, so we need to perform extraploation here. We would try to evaluate results using different methods of extrapolation such as pchip, linear & extrap, pchip & extrap, spline+extrap.
filename = 'VI.xlsx'; %Defining filename of Excel file
[V] = xlsread(filename,'A2:A25'); %Reading values from excel for V
[I] = xlsread(filename,'B2:B25'); %Reading values from excel for I
Vq = [-17.3:0.1:0.9]; %Defining data range to be interpolated
Iq1 = interp1(V,I,Vq,'pchip'); %Interpolation using method pchip
Iq2 = interp1(V,I,Vq,'linear','extrap'); %Interpolation using method linear+extrap
Iq3 = interp1(V,I,Vq,'pchip','extrap'); %Interpolation using method pchip+extrap
Iq4 = interp1(V,I,Vq,'spline','extrap'); %Interpolation using method spline+extrap
figure(1);
plot(V,I,'o',Vq,Iq1,'-');title('Interploation by pchip method');xlabel('Vq');ylabel('Iq1');
figure(2);
plot(V,I,'o',Vq,Iq2,'-');title('Interploation by linear+extrap method');xlabel('Vq');ylabel('Iq2');
figure(3);
plot(V,I,'o',Vq,Iq3,'--');title('Interploation by pchip+extrap method');xlabel('Vq');ylabel('Iq3');
figure(4);
plot(V,I,'o',Vq,Iq4,'--');title('Interploation by spline+extrap method');xlabel('Vq');ylabel('Iq4');
A = [Vq;Iq1];
B = [Vq;Iq2];
C = [Vq;Iq3];
D = [Vq;Iq4];
%Creating text file for interpolated data using method pchip
filename = fopen('Data1.txt','w');
fprintf(filename,'%6s %6s\n','Vq','Iq1');
fprintf(filename,'%6.2f %6.2f \n',A);
fclose(filename);
%Creating text file for interpolated data using method linear+extrap
filename = fopen('Data2.txt','w');
fprintf(filename,'%6s %6s\n','Vq','Iq2');
fprintf(filename,'%6.2f %6.2f \n',B);
fclose(filename);
%Creating text file for interpolated data using method pchip+extrap
filename = fopen('Data3.txt','w');
fprintf(filename,'%6s %6s\n','Vq','Iq3');
fprintf(filename,'%6.2f %6.2f \n',C);
fclose(filename);
%Creating text file for interpolated data using method spline+extrap
filename = fopen('Data4.txt','w');
fprintf(filename,'%6s %6s\n','Vq','Iq4');
fprintf(filename,'%6.2f %6.2f \n',D);
fclose(filename);
Graphical representation of Interpolated data:


Conclusion:
1. The given data in teh excel file is read into Matlab.
2. Interpolation is performed in the specified data range, using different methods and saved to respective text files. The missing data is in the range 0.65 to 0.9 can be found from teh text files.
File 'Data1.txt' contains interpolated data by using pchip method.
File 'Data2.txt' contains interpolated data by using linear+extrap method.
File 'Data3.txt' contains interpolated data by using pchip+extrap method.
File 'Data4.txt' contains interpolated data by using spline+extrap method.
- It can be seen that results obtained by method pchip and pchip+extrap are same. This means that pchip method alone does the extrapolation, but linear method cannot extrapolate alone. So, extrap method has to be used along with linear method.
- The results obtained by pchip and linear+extrap are fairly same within teh data specified data range, but vary beyond the data range.
- The results obtained by spline+extrap vary significantly as that obtained by pchip method. So, spline method should not be used for extrapolation. Here, teh method is used only for demonstration and comparison purpose.
3. The MATLAB script file is attached.
4. All the text files and figures are attached.