Project - Data Handling and Interpolation
Answer: Aim: In a laboratory experiment, data of voltage and current has been recorded and the same is attached in an excel file VI.xlsx, 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.
Code:
[data]=xlsread('VI.xlsx'); %load the given data
V=data(:,1);
I= data(:,2);
x=-17.3:0.1:0.9; %set the given range for interpolation
subplot(211)
plot(V,I,'*r')
title('without Interpolation')
xlabel('Voltage')
ylabel('Current')
Y=interp1(V,I,x); % interpolate for the given range and assign in Y
subplot(212)
plot(Y,'*y')
figure(1)
plot(V,I,'*r',x,Y,'-y');
title('with Interpolation')
xlabel('Voltage')
ylabel('Current')
fileID=fopen('interp_result.txt','w'); %stored the interpolated data
fprintf(fileID,'%8s %13s\n', 'V(volt)', 'I(mAmp)');
fprintf(fileID,'%f %f\n' ,Y);
fclose(fileID);
Result:
