Project - Data Handling and Interpolation
% Project Data Handling & Interpolation.
% Read the excel file;
data = readtable('ISA_PROJECT1_Q2_DATA.xlsx'); % It reads the Excel file into a table.
voltage = data{:, 1}; % Assuming Voltage is in the first column
current = data{:, 2}; % Assuming Current is in the second column.
% Define interpolation range.
interp_range = -17.3:0.1:0.9; % Defining the Interpolation range from -17.3 to 0.9 with a step size of 0.1.
%Perform interpolation.
interp_current = interp1(voltage, current, interp_range, 'linear', 'extrap'); % It's for linear interpolation which calculates the current values corresponding to the specified range of voltages.
% Identify interpolated (missing) data.
% Calculate missing points where interpolation was required
missing_data = interp_range(~ismember(interp_range, voltage)); % Missing points in the original dataset (those not directly measured) are identified using the ismember function.
missing_interp = interp_current(~ismember(interp_range, voltage)); %
% Save missing data to a text file
missing_table = table(missing_data', missing_interp', 'VariableNames', {'Voltage', 'Interpolated_Current'});
writetable(missing_table, 'missing_data.txt', 'Delimiter', '\t'); % The missing points are saved into text files.
% Save full interpolated data to a text file
full_data_table = table(interp_range', interp_current', 'VariableNames', {'Voltage', 'Current'});
writetable(full_data_table, 'interpolated_data.txt', 'Delimiter', '\t'); % The interpolated values are saved into text files
% Plot the data
figure('Name','Comparison of Original & Interpolated Voltage-Current Characteristics')
subplot(221); plot(voltage, current, 'r', 'DisplayName', 'Original Data')
title('Original Voltage-Current Characteristics');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('show');
grid on;
subplot(222); plot(interp_range, interp_current, 'g', 'DisplayName', 'Interpolated Data');
title('Interpolated Voltage-Current Characteristics');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('show');
grid on;
% Enable interactive plot
datacursormode on; %The original and interpolated data are plotted for visualization. it allows the user to interact with the plot.
disp('Interpolation complete. Files saved: missing_data.txt, interpolated_data.txt');
%