Challenge

Project - Data Handling and Interpolation

Project - Data Handling and Interpolation:

Code:

%To read the Excel File xlsread is used here
A=xlsread("VI.xlsx");
%To take first coloumn input from Excel file A(:,1) is used here
Volt=A(:,1);
%To take second coloumn input from Excel file A(:,2) is used here
Current=A(:,2);
%New_Range variable is used to set interpolation data limit given in question
New_Range=[-17.3:0.1:0.9];
%interp1() function is used to get the more current point for a given limit
B=interp1(Volt,Current,New_Range);
%plot is used to plot the graph with excel sheet value
%hold on used to hold the graph sheet and draw another graph
plot(Volt,Current,'b-');hold on;grid;
%plot is used here to plot the graph with New_Range and Interpolation point
plot(New_Range,B,'o');
%xlabel() function is used to view the "Voltage(V)" text in x-axis
xlabel("Voltage(V)");
%ylabel() function is used to view the "Current(mA)" text in y-axis
ylabel("Current(mA)");
%title() function is used to veiw the "Current vs Voltage" text in title place
title("Current vs Voltage");
%legend() function is used differentate the two graph point
legend("Before Interpolation","After Interpolation",Location="south");
%Here I used nested-for-loop for take the missing point between before interpolation point and after interpolation point
for i=1:length(B)%to take all value in 'B'
for j=1:length(Current)%to take all value in 'Current'
if(Current(j)==B(i))%Compare 'B' and 'Current' point if it present set as zero
B(i)=0;%To set the available plot to zero
end
end
end
%To open the text file 'Missing_plot.txt' fopen is used and 'w' to write the txt file
d=fopen("Missing_Plot.txt",'w');
%To print the line in text file fprintf() is used
fprintf(d,"Current(mA)\n");
%I convert all the available point to zero,if i remove all zero and not an
%number then i get missing point,so i used for loop to perform that
for i=1:length(B)
if~(B(i)==0 || isnan(B(i)))
fprintf(d,"%s\n",num2str(B(i)));%To save the point in text file
%for clear point value i used num2str function
end
end
fclose(d);%After edit I closed the file here
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.