Challenge

Project - Data Handling and Interpolation

Project - Data Handling & Interpolation

Solution:

Program:

% Data Handling & Interpolation 
% Perform Interpolation for finding missing data between Voltage & Current
clc                                                                        % To clear the command window
clear all                                                                  % To clear workspace
close all                                                                  % To close all opened files
V_I=xlsread('VI.xlsx');                                                    % Read Votage & Current data from excel file 
V=V_I(:,1);                                                                % Store Voltage date in variable V
I=V_I(:,2);                                                                % Store Current data in varialbe I
x=-17.3:0.1:0.9;                                                           % perform interpolation in range x
y1=interp1(V,I,x);                                                         % specify linear interpolation
y2=interp1(V,I,x,'spline');                                                % specify spline interpolation
subplot(2,1,1);            
plot(V,I,'o',x,y1,'--');grid on;xlabel('Current I');ylabel('Voltage V');   % plot the linear interpolation graph
title('V-I Linear Interpolation');                                         % Labelled the graph as linear interpolation 
subplot(2,1,2);
plot(V,I,'o',x,y2,'--');grid;xlabel('Current I');ylabel('Voltage V');      % Plot the spline interpolation graph
title('V-I Spline Interpolation');                                         % Labelled the graph as spline interpolation
z=[x;y1];
fid=fopen('V-I.txt','w');                                                  % store the V-I data in text file
fprintf(fid,'%f \n',z);                                                    % Display the output in command window
fclose(fid)                                                                % close fileid

Output:

Fig. Graph between Current & Voltage with linear & spline interpolation

Missing data:

Text file Output:

Fig. Screenshot of text file (Missing data)

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.