Project - Data Handling and Interpolation
clc; clear; close all;
%% 1. Read Data from Excel File
data = xlsread('VI_Data_Large.xlsx'); % Read the large dataset (100 points)
Voltage = data(:,1); % First column (Voltage)
Current = data(:,2); % Second column (Current)
%% 2. Interpolation in Given Range (-17.3V to 0.9V)
V_interp = -17.3:0.1:0.9; % Voltage range for interpolation
I_interp = interp1(Voltage, Current, V_interp, 'spline'); % Spline interpolation
%% 3. Save Interpolated Data to a Text File
fileID = fopen('Interpolated_VI_Data.txt', 'w');
fprintf(fileID, 'Voltage (V)\tCurrent (I)\n'); % Column headers
for i = 1:length(V_interp)
fprintf(fileID, '%.2f\t%.4f\n', V_interp(i), I_interp(i));
end
fclose(fileID);
disp('Interpolated data saved to Interpolated_VI_Data.txt');
%% 4. Interactive Plot
figure;
plot(Voltage, Current, 'ro', 'MarkerSize', 6, 'DisplayName', 'Original Data'); hold on;
plot(V_interp, I_interp, 'b-', 'LineWidth', 1.5, 'DisplayName', 'Interpolated Data');
xlabel('Voltage (V)');
ylabel('Current (I)');
title('Voltage-Current Interpolation');
legend('Location', 'northwest');
grid on;
% Making plot interactive
disp('Click on the plot to display voltage and current values.');
datacursormode on;