Challenge

Project - Data Handling and Interpolation

Q. No. 1 : Project - Data Handling and Interpolation

M-Script Coding File :

% Interpolation of Voltage and Current Data
clc;
clear all;
A=xlsread("VI.xlsx"); % Reading the excel file data named VI.xlsx
V=A(:,1); % Separating the Voltage Data from column 1 of the excel file
I=A(:,2); % Separating the Voltage Data from column 2 of the excel file
r=(-17.9:0.1:0.9); % Given Interpolation Range
yq1=interp1(V,I,r); %Linear Interpolation
yq2=interp1(V,I,r,'spline'); % Spline Interpolation
% Linear Interpolation plotting in Figure 1
figure(1);
plot(V,I,'o',r,yq1,':.'); % Plot the Linear Interpolation curve
grid on; % Enable the Grid
title('Linear Interpolation'); % Title the Plot
xlabel('Voltage (V)'); % Labels the X side
ylabel('Current (I)'); % Labels the Y side
legend('Actual Value','Interpolated Value'); % Specify the Legends
print('Linear Interpolation','-dpng'); % Output of Plot in Image(.png) file
% Linear Interpolation plotting in Figure (2)
figure(2);
plot(V,I,'o',r,yq2,'m:.'); % Plot the Spline Interpolation curve
grid on; % Enable the Grid
title('Spline Interpolation'); % Title the Plot
xlabel('Voltage (V)'); % Labels the X side
ylabel('Current (I)'); % Labels the Y side
legend('Actual Value','Interpolated Value'); % Specify the Legends
print('Spline Interpolation','-dpng'); % Output of Plot in Image(.png) file
% Saving the Interpolation Data into Text (.txt) file
volt_curr=fopen('VI_Output.txt','w'); % Opening the output text file (VI_Output.txt)
fprintf(volt_curr,'Voltage Current\n');
fprintf(volt_curr,'%1.3f %1.3f\n',r,yq2); % Writing the Voltage and Current Value in the output text file
fclose(volt_curr);
vv=[-17.2
-13
-11
-9
-6
-1
0.11
0.25
0.5
0.61
0.66]; % Create a new variable vv and put the voltage of missing current
ii=interp1(V,I,vv); % Interpolate to find the missing current
z=[vv ii]; % Create a variable z and store the voltage and missing current in it
writematrix(z,'Missing_Output_Value.txt'); % Output of Voltage and Missing Current Data in matrix format in text(.txt) file

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.