Project - Data Handling and Interpolation
clc;
close all ;
clear all;
format long;
[Filename Pathname] = uigetfile('*.xlsx','Pick a file');%select the file from the saved path
I = [Pathname Filename]; % get its pathname and filename
u=xlsread(I);% load the data to u
v_V=u(:,1);% read voltage value
I_mA=u(:,2);% read current value
figure
plot(v_V,I_mA) %plot voltage vs current
z=-17.3:0.01:0.9; % interpolation range
z1=interp1(v_V,I_mA,z);% interpolate the data
w=[z; z1]; % voltage and current as row vector
w=w';% convert to column vector
hold on % hold the recorded figure
plot(z,z1,'o') %plot the interpolated value
xlabel("Voltage V") % voltage in x axis
ylabel("Current, mA") %
title("Voltage vs. Current")
legend("Recorded Value","Interpolated Value")
VV =[-17.2 -17.1 -13.8 -13.5 -13.0 -12.5 -11 -9 -5.76 -6 -1 0.11 0.25 0.5 0.609];
fhandle=fopen('E:\skilllync\matlab\challenges\voltagecurrent.txt','w'); %pointer to fhandle
r=[];
for i=1:length(VV)
for j=1:length(w)
if w(j,1)==VV(i)
r(i)=w(j,2)
end
end
end
fprintf(fhandle,'%d\n',r);
fclose(fhandle);


