Challenge

Project - Data Handling and Interpolation

Q. 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.

                                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]’

fid = xlsread('VI.xlsx')
a=VI(:,1);
b=VI(:,2);
h = -17.3:0.1:0.9
yq1=interp1(a,b,h); 
yq2=interp1(a,b,h,'spline'); 
figure(1);
plot(a,b,'o',h,yq1);
grid;
title('Linear Interpolation');
figure(2);
plot(a,b,'o',h,yq2);
grid;
title('Spline Interpolation');
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]'
k=interp1(a,b,VV,'spline'); 
fid = fopen('VV.txt','w')
fprintf(fid,'%5f %5f\n',VV,k)
fclose(fid)
fid =

  -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


h =

  Columns 1 through 12

  -17.3000  -17.2000  -17.1000  -17.0000  -16.9000  -16.8000  -16.7000  -16.6000  -16.5000  -16.4000  -16.3000  -16.2000

  Columns 13 through 24

  -16.1000  -16.0000  -15.9000  -15.8000  -15.7000  -15.6000  -15.5000  -15.4000  -15.3000  -15.2000  -15.1000  -15.0000

  Columns 25 through 36

  -14.9000  -14.8000  -14.7000  -14.6000  -14.5000  -14.4000  -14.3000  -14.2000  -14.1000  -14.0000  -13.9000  -13.8000

  Columns 37 through 48

  -13.7000  -13.6000  -13.5000  -13.4000  -13.3000  -13.2000  -13.1000  -13.0000  -12.9000  -12.8000  -12.7000  -12.6000

  Columns 49 through 60

  -12.5000  -12.4000  -12.3000  -12.2000  -12.1000  -12.0000  -11.9000  -11.8000  -11.7000  -11.6000  -11.5000  -11.4000

  Columns 61 through 72

  -11.3000  -11.2000  -11.1000  -11.0000  -10.9000  -10.8000  -10.7000  -10.6000  -10.5000  -10.4000  -10.3000  -10.2000

  Columns 73 through 84

  -10.1000  -10.0000   -9.9000   -9.8000   -9.7000   -9.6000   -9.5000   -9.4000   -9.3000   -9.2000   -9.1000   -9.0000

  Columns 85 through 96

   -8.9000   -8.8000   -8.7000   -8.6000   -8.5000   -8.4000   -8.3000   -8.2000   -8.1000   -8.0000   -7.9000   -7.8000

  Columns 97 through 108

   -7.7000   -7.6000   -7.5000   -7.4000   -7.3000   -7.2000   -7.1000   -7.0000   -6.9000   -6.8000   -6.7000   -6.6000

  Columns 109 through 120

   -6.5000   -6.4000   -6.3000   -6.2000   -6.1000   -6.0000   -5.9000   -5.8000   -5.7000   -5.6000   -5.5000   -5.4000

  Columns 121 through 132

   -5.3000   -5.2000   -5.1000   -5.0000   -4.9000   -4.8000   -4.7000   -4.6000   -4.5000   -4.4000   -4.3000   -4.2000

  Columns 133 through 144

   -4.1000   -4.0000   -3.9000   -3.8000   -3.7000   -3.6000   -3.5000   -3.4000   -3.3000   -3.2000   -3.1000   -3.0000

  Columns 145 through 156

   -2.9000   -2.8000   -2.7000   -2.6000   -2.5000   -2.4000   -2.3000   -2.2000   -2.1000   -2.0000   -1.9000   -1.8000

  Columns 157 through 168

   -1.7000   -1.6000   -1.5000   -1.4000   -1.3000   -1.2000   -1.1000   -1.0000   -0.9000   -0.8000   -0.7000   -0.6000

  Columns 169 through 180

   -0.5000   -0.4000   -0.3000   -0.2000   -0.1000         0    0.1000    0.2000    0.3000    0.4000    0.5000    0.6000

  Columns 181 through 183

    0.7000    0.8000    0.9000


VV =

  -17.2000
  -17.1000
  -13.8000
  -13.5000
  -13.0000
  -12.5000
  -11.0000
   -9.0000
   -5.7600
   -6.0000
   -1.0000
    0.1100
    0.2500
    0.5000
    0.6100


fid =

     4


ans =

   302


ans =

     0

Plots :

                             

                               

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.