Challenge

Project - Data Handling and Interpolation

%Project :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.
clear;
clc;
%Reading the data from Excel file
VI = xlsread('VI.xlsx');
V = VI(:,1);
I = VI(:,2);
%Geting the voltage range for interpolation
Vrange = -17.3:0.1:0.9;
%Interpolate the current for given voltage and plote the raw voltage v\s raw current and given voltage v\s interpolated current.
Iinterpolated = interp1 (V,I,Vrange,"spline");
%Writing the given voltage and interpolated current in a text file
fileID = fopen('VIinterpolated.txt','w');
fprintf(fileID, '%f, %f\n', Vrange,Iinterpolated);
fclose(fileID);
plot(V,I,'ok'); grid on; hold on; title ('Voltage v/s current');
xlabel('Voltage(volts)'); ylabel ('Current(Amps)');
plot(Vrange,Iinterpolated, 'r-');
%Geting the Voltage range for corrent interpolating and entering to text file.
Vreq =[-17.2 -13 -11 -9 -6 -1 0.11 0.25 0.5 0.61 0.66];
Ireq = interp1(V,I, Vreq, "spline");
VIreq = [Vreq;Ireq];
%Appending the interpolated data into the text file.
fileID = fopen('VIinterpolated.txt','a');
fprintf(fileID, '%f, %f\n', VIreq);
fclose(fileID);
Expected output:

>> Vreq

Vreq =

-17.2000 -13.0000 -11.0000 -9.0000 -6.0000 -1.0000 0.1100 0.2500 0.5000 0.6100 0.6600

>> Ireq

Ireq =

-28.1734 -2.4298 -1.6103 -1.1164 -0.7445 -0.2906 0.0012 -0.0001 0.1700 1.5665 4.8092

also find the attached file for the output

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.