Challenge

Project - Data Handling and Interpolation

Project

%Project to perform Interpolation function.
clc
data3=0;
data=xlsread('VI.xlsx');%Load the data in the Excel to Matlab
Vol=data(1:24,1);%load voltage data to a variable
intre=(-17.3:0.1:0.9);%defining the range and intervel
intra2=(-17.3:0.01:0.9);
Cur=data(1:24,2);%load current data to a variable
y=interp1(Vol,Cur,intre);%obtaining y values bu intepolation
y1=interp1(Vol,Cur,intra2);
figure(1);
plot(intre,y,'m.');%Plot of interpolated data
hold on
data2=xlsread('VI.xlsx','Sheet2');%load data in sheet 2 to find thecorresponding y value
plot(Vol,Cur,'b-');%Plot of actual voltage and current values
hold on;
for i=1:length(data2)%loop too obtain current values corresponding to poroblem data given
for k=1:length(intra2)
if(data2(i)==intra2(k))
data3(i)=y1(k);
end
end
end
xlabel('Voltage');
ylabel('Current');
grid;
title('Voltage vs Current');
plot(data2,data3,'ro');
legend('Location','best');
legend('Intrapolated','Actual','Problem data');
fileID=fopen('interpolated1.txt','w');%opened a file to rwite the values
Voltage=intre;
Current=y;
T=table(Voltage',Current','VariableNames',{'Voltage','Current'});%to ceate a table
writetable(T,'interpolated1.txt');%to write the data into the text file
fclose(fileID);

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.