Project - Data Handling and Interpolation
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:
MATLAB code:
% Read data from Excel file
data = xlsread('VI.xlsx');
% Extract voltage and current columns
voltage = data(:,1);
current = data(:,2);
% Define the voltage range for interpolation
vq = -17.3:0.1:0.9;
% Interpolate current values based on voltage range
current_interp = interp1(voltage, current, vq);
% Generate interactive plot
figure;
plot(voltage, current, 'o', vq, current_interp);
xlabel('Voltage');
ylabel('Current');
title('VI Characteristics');
legend('Data', 'Interpolated');
% Save interpolated data to text file
fileID = fopen('VI_interpolated.txt','w');
fprintf(fileID,'%12s %12s\n', 'Voltage', 'Current');
fprintf(fileID,'%12.4f %12.4f\n',[vq; current_interp]);
fclose(fileID);
Here, the data us first read from the given excel file, and the extracted voltage and current values are then used to perform interpolation using the 'interp1' function. The resulting interpolated data is then plotted on an interactive plot, with the voltage values on the x-axis and the current values on the y-axis. The plot is given appropriate axis labels and a title. Then interpolated data is saved to a text file. The resulting text file contains two columns, one for voltage and one for current, separated by a space.

Workspace:

Result:
