Challenge

Project - Data Handling and Interpolation

Project:
In a laboratory experiment, data of voltage and current has been recorded and the same is attached in an excel file ( 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. Additionally, compute the current values for given voltages below and store them in a text file.


Result:

a)Code

clc
clear all
close all
data=xlsread('VI.xlsx')       %Reading the xlsx file
V= data(:,1)                   % sorting first column value of 'data' in 'v'
I= data(:,2)                   % Sorting second column value of 'data' in'A'
Vinp = -17.3:0.1:0.9;          % Creating given range of Voltage data mentioned in problem
Iinp = interp1(V,I,Vinp,'spline');  % Using 'interp1' function for calculating
 
% Current value for given %Voltage Range 'Vinp'
figure(1);
subplot(121)
plot(V,I,'-o');grid;           % Plotting graph
title('Given Data');           % giving tile for graph
ylabel('I(mAmp)');xlabel('V(volt)');  % given labels to x and y axis

figure(2);
plot(V,I,'o',Vinp,Iinp);grid;     % Ploting values
title('Voltage(V) vs Current(I) validation plot');  %Giveing title for figure
xlabel('V(volt)');ylabel('I(mAmp)');    % Given x and y axis
legend ('Experiment Data','Calculated by interpolation','Location','Best');   % Showing legends
VV= [-17.2 -13 -11 -9 -6 -1 0.11 0.25 0.5 0.61 0.66]    % Given data
VI=interp1(V,I,VV,'spline')    % using 'interp1' function for calculating current value for given voltage
figure(3);
plot(VV,VI,'-o');grid;         % Ploting the values
title('Calculated value of I(mAmp) vs given data of V(volt)'); %giving title for figure 3
xlabel('V(volt)');ylabel('I(mAmp)');       % Labeling x and yaxis 

fid = fopen('Volt_and_Current.txt','w');   % Opening output file 
fprintf(fid,'V(volt) I(mAmp)\n');          % Storing value of variable x in file 
for i= 1: length(VV')
   fprintf(fid,'%.3f %.3f\n',VV(i),VI(i)); % Storing value of variable x in file
end
 
fclose(fid);              % closing output file 
result=[VV' VI']          % required result 


Output Results:

b) Given data
data =

  -17.3000  -28.0000
  -17.1000  -24.0000
  -17.0000  -19.0000
  -16.8000  -14.0000
  -16.5000   -9.0000
  -16.0000   -6.0000
  -15.0000   -4.0000
  -14.0000   -3.0000
  -12.0000   -2.0000
  -10.0000   -1.3000
   -8.0000   -1.0000
   -5.0000   -0.6000
   -2.0000   -0.3000
   -0.2000   -0.1000
    0.0900         0
    0.1900         0
    0.2700         0
    0.3900    0.0100
    0.4300    0.0300
    0.5000    0.1700
    0.5500    0.4200
    0.6000    1.2300
    0.6200    1.9900
    0.6500    3.9100


V =

  -17.3000
  -17.1000
  -17.0000
  -16.8000
  -16.5000
  -16.0000
  -15.0000
  -14.0000
  -12.0000
  -10.0000
   -8.0000
   -5.0000
   -2.0000
   -0.2000
    0.0900
    0.1900
    0.2700
    0.3900
    0.4300
    0.5000
    0.5500
    0.6000
    0.6200
    0.6500


I =

  -28.0000
  -24.0000
  -19.0000
  -14.0000
   -9.0000
   -6.0000
   -4.0000
   -3.0000
   -2.0000
   -1.3000
   -1.0000
   -0.6000
   -0.3000
   -0.1000
         0
         0
         0
    0.0100
    0.0300
    0.1700
    0.4200
    1.2300
    1.9900
    3.9100

c) Required result for VV =[-17.2  -17.1  -13.8  -13.5  -13.0  -12.5  -11   -9   -5.76   -6   -1    0.11    0.25   0.5    0.61   0.66]’

VV =

  -17.2000  -13.0000  -11.0000   -9.0000   -6.0000   -1.0000    0.1100    0.2500    0.5000    0.6100    0.6600


VI =

  -28.1734   -2.4298   -1.6103   -1.1164   -0.7445   -0.2906    0.0012   -0.0001    0.1700    1.5665    4.8092


result =

  -17.2000  -28.1734
  -13.0000   -2.4298
  -11.0000   -1.6103
   -9.0000   -1.1164
   -6.0000   -0.7445
   -1.0000   -0.2906
    0.1100    0.0012
    0.2500   -0.0001
    0.5000    0.1700
    0.6100    1.5665
    0.6600    4.8092

>> Calculated Result

V(volt) I(mAmp)
-17.200 -28.173
-13.000 -2.430
-11.000 -1.610
-9.000 -1.116
-6.000 -0.745
-1.000 -0.291
0.110 0.001
0.250 -0.000
0.500 0.170
0.610 1.567
0.660 4.809
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.