Challenge

Project - Data Handling and Interpolation

                                                                                             Project

                                                                              Data Handling and Interpolation

AIM:

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.

Key Highlights:

  • Graphical solutions are more visual and appealing
  • Interpolation of data
  • Read excel file
  • Write to text file

Deliverables:

  • Find missing data and save it in text
  • Interpolate the data set
  • Save your program and attach the same. 
  • Save txt file and upload in attachment

Answer:

Interpolation: 

Interpolation is the process of creating a new value based on the values already present in a set of data. The act of inserting or interjecting a middle value between two other values is another way to put it.

Interpolation is the process of determining a function's value in data science or mathematics based on the values of other datapoints in a given sequence. The known x values may range from x0 to xn, and this function may be written as f(x).

To determine and display interpolated data for provided data, use the interp1 function.

Read the data and store it in the variable x using the xlsread function.

  • The first column of that was retrieved, representing voltage data, and the second column, representing current data, representing variable C.complete the interpolation between -17.3:0.1:0.9 It should be saved in the Vq variable.

  • Then, using the function interp1 yq1, we added a range of data and interpolated the curve.
  • Using the spline interpolation method yq2, smooth the data.
  • the VVSI data, the second VVSI data with a linear interpolated curve, and the third VVSI data with a spline interpolated curve were then plotted.
  • We initially use the fopen function pointer named f to open the file in write mode for storing the interpolated data.
  • The VoltageCurrentData.txt file contains the data that we printed using the for loop
    and saved the file.

MATLAB CODE:

clear;
clc;

% interpolation of voltage and current data
% read data excel file data
D=xlsread('VI.xlsx');

v=D(:,1); % voltage data seperating
i=D(:,2); % current data seperating
xq=[-17.3:0.1:0.9]; % Given interpolation range

% linear interpolation
yq1=interp1(v,i,xq); 
% spline interpolation
yq2=interp1(v,i,xq,'spline'); 

% Linear interpolation plot
figure(1)
plot(v,i,'s',xq,yq1,': .');
title('Linear Interpolation');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;

% spline interpolation plot
figure(2)
plot(v,i,'s',xq,yq2,'b: .');
title('SPLINE INTERPOLATION');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;

% saving the interpolation data into text file.txt
%opening the txt file
Text_file=fopen('VI_output.txt','w');
fprintf(Text_file,' Voltage  Current\n');

%writing voltage & current value
fprintf(Text_file,'%4.3f  %5.3f\n',xq,yq2);

%saving linear interpolation graph
savefig(1,'vilinear.fig');

%saving spline interpolation graph
savefig(2,'vispline.fig');
fclose(Text_file);

RESULT: OUTPUT

THE TEXT IS CREATED AND SAVED:

Workspace:

Conclusion:

We successfully do the interpolation in the range of -17.3:0.1:0.9, according to the results. create an interactive plot for the interpolated data as well as save it in a text 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.