Challenge

Project - Data Handling and Interpolation

Project:

Ans:

%Program

% Save the excel file with name data.xlsx in the same directory of the
% MATLAB and load the data with below
data = xlsread('data.xlsx');
V = data(:,1); % Voltage data is in the first column
I = data(:,2); % Current data is in the second column
% Create a vector of desired voltages
V_interp = linspace(-17.3, 0.9, 191);
% Interpolate the current data
I_interp = interp1(V, I, V_interp);
% Generating interactive plot
figure;
plot(V, I, '*r', V_interp, I_interp, '--b');
xlabel('Voltage (V)');
ylabel('Current (A)');
title('Interpolated Current vs. Voltage');
legend('Original Data', 'Interpolated Data');
% Save the interpolated data into a text file shown below
fileID = fopen('interpolated_data.txt', 'w');
fprintf(fileID, 'Voltage(V)\tCurrent(I)\n');
for i = 1:length(V_interp)
fprintf(fileID, '%f\t%f\n', V_interp(i), I_interp(i));
end
fclose(fileID);
Results:
attached to this file - Plot name : Project_4_interpolate.fig
File generated and stored in : Interpolated_data.txt
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.