Challenge

Project - Data Handling and Interpolation

Script file-

f = xlsread('VI.xlsx')                                 % read thee excel file in matlab

v = f(:,1);                                            % read the column 1 as voltage

i = f(:,2)                                             % read the column 2 as current

x = [-17.3:0.1:0.9]                                    % defined the range

y = interp1(v,i,x)                                     % interpolation command used to interpolate values
         
plot(v,i,'m',x,y)                                      % plot command used to plot graph

grid;                                                  %grid on

xlabel('Voltage_in_volts');                            % label the x axis as voltage

ylabel('Current_in_amp');                              % label the y axix as current

title('VI_interpolation')                              % title given

z = [VI]                                              

filename = fopen('interpolation_output.txt','w');       %save the output file as a text file,'w' as write access 
fprintf(filename,'%d \t',y);
fclose(filename);                                       %closing the file

Output command window-

>> matlab_project

f =

  -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


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


x =

  Columns 1 through 13

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

  Columns 14 through 26

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

  Columns 27 through 39

  -14.7000  -14.6000  -14.5000  -14.4000  -14.3000  -14.2000  -14.1000  -14.0000  -13.9000  -13.8000  -13.7000  -13.6000  -13.5000

  Columns 40 through 52

  -13.4000  -13.3000  -13.2000  -13.1000  -13.0000  -12.9000  -12.8000  -12.7000  -12.6000  -12.5000  -12.4000  -12.3000  -12.2000

  Columns 53 through 65

  -12.1000  -12.0000  -11.9000  -11.8000  -11.7000  -11.6000  -11.5000  -11.4000  -11.3000  -11.2000  -11.1000  -11.0000  -10.9000

  Columns 66 through 78

  -10.8000  -10.7000  -10.6000  -10.5000  -10.4000  -10.3000  -10.2000  -10.1000  -10.0000   -9.9000   -9.8000   -9.7000   -9.6000

  Columns 79 through 91

   -9.5000   -9.4000   -9.3000   -9.2000   -9.1000   -9.0000   -8.9000   -8.8000   -8.7000   -8.6000   -8.5000   -8.4000   -8.3000

  Columns 92 through 104

   -8.2000   -8.1000   -8.0000   -7.9000   -7.8000   -7.7000   -7.6000   -7.5000   -7.4000   -7.3000   -7.2000   -7.1000   -7.0000

  Columns 105 through 117

   -6.9000   -6.8000   -6.7000   -6.6000   -6.5000   -6.4000   -6.3000   -6.2000   -6.1000   -6.0000   -5.9000   -5.8000   -5.7000

  Columns 118 through 130

   -5.6000   -5.5000   -5.4000   -5.3000   -5.2000   -5.1000   -5.0000   -4.9000   -4.8000   -4.7000   -4.6000   -4.5000   -4.4000

  Columns 131 through 143

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

  Columns 144 through 156

   -3.0000   -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 169

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

  Columns 170 through 182

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

  Column 183

    0.9000


y =

  Columns 1 through 13

  -28.0000  -26.0000  -24.0000  -19.0000  -16.5000  -14.0000  -12.3333  -10.6667   -9.0000   -8.4000   -7.8000   -7.2000   -6.6000

  Columns 14 through 26

   -6.0000   -5.8000   -5.6000   -5.4000   -5.2000   -5.0000   -4.8000   -4.6000   -4.4000   -4.2000   -4.0000   -3.9000   -3.8000

  Columns 27 through 39

   -3.7000   -3.6000   -3.5000   -3.4000   -3.3000   -3.2000   -3.1000   -3.0000   -2.9500   -2.9000   -2.8500   -2.8000   -2.7500

  Columns 40 through 52

   -2.7000   -2.6500   -2.6000   -2.5500   -2.5000   -2.4500   -2.4000   -2.3500   -2.3000   -2.2500   -2.2000   -2.1500   -2.1000

  Columns 53 through 65

   -2.0500   -2.0000   -1.9650   -1.9300   -1.8950   -1.8600   -1.8250   -1.7900   -1.7550   -1.7200   -1.6850   -1.6500   -1.6150

  Columns 66 through 78

   -1.5800   -1.5450   -1.5100   -1.4750   -1.4400   -1.4050   -1.3700   -1.3350   -1.3000   -1.2850   -1.2700   -1.2550   -1.2400

  Columns 79 through 91

   -1.2250   -1.2100   -1.1950   -1.1800   -1.1650   -1.1500   -1.1350   -1.1200   -1.1050   -1.0900   -1.0750   -1.0600   -1.0450

  Columns 92 through 104

   -1.0300   -1.0150   -1.0000   -0.9867   -0.9733   -0.9600   -0.9467   -0.9333   -0.9200   -0.9067   -0.8933   -0.8800   -0.8667

  Columns 105 through 117

   -0.8533   -0.8400   -0.8267   -0.8133   -0.8000   -0.7867   -0.7733   -0.7600   -0.7467   -0.7333   -0.7200   -0.7067   -0.6933

  Columns 118 through 130

   -0.6800   -0.6667   -0.6533   -0.6400   -0.6267   -0.6133   -0.6000   -0.5900   -0.5800   -0.5700   -0.5600   -0.5500   -0.5400

  Columns 131 through 143

   -0.5300   -0.5200   -0.5100   -0.5000   -0.4900   -0.4800   -0.4700   -0.4600   -0.4500   -0.4400   -0.4300   -0.4200   -0.4100

  Columns 144 through 156

   -0.4000   -0.3900   -0.3800   -0.3700   -0.3600   -0.3500   -0.3400   -0.3300   -0.3200   -0.3100   -0.3000   -0.2889   -0.2778

  Columns 157 through 169

   -0.2667   -0.2556   -0.2444   -0.2333   -0.2222   -0.2111   -0.2000   -0.1889   -0.1778   -0.1667   -0.1556   -0.1444   -0.1333

  Columns 170 through 182

   -0.1222   -0.1111   -0.1000   -0.0655   -0.0310         0         0    0.0025    0.0150    0.1700    1.2300       NaN       NaN

  Column 183

       NaN


z =

  24×2 table

    VVolt    ImAmp
    _____    _____

    -17.3     -28 
    -17.1     -24 
      -17     -19 
    -16.8     -14 
    -16.5      -9 
      -16      -6 
      -15      -4 
      -14      -3 
      -12      -2 
      -10    -1.3 
       -8      -1 
       -5    -0.6 
       -2    -0.3 
     -0.2    -0.1 
     0.09       0 
     0.19       0 
     0.27       0 
     0.39    0.01 
     0.43    0.03 
      0.5    0.17 
     0.55    0.42 
      0.6    1.23 
     0.62    1.99 
     0.65    3.91 

>> 

Graph-

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.