1

I have lab test data from a battery discharge curve. The data consistes in 22 points of voltage versus time. In matlab I have traced an interpolation curve through spline interpolation, but I wish to make the derivative of this plot, how can I do this?

enter image description here

Code

x = [0; 3600    ;7200   ;10800; 14400;  18000;  21600;  25200   ;28800;...
32400;  36000   ;39600  ;43200  ;46800; 50400   ;54000; 57600;  61200;...
64800   ;68400  ;72000; 74880];
y = [12.75; 12.40;  12.38;  12.34;  12.30;  12.26   ;12.21  ;12.17  ;...
 12.12; 12.07;  12.02   ;11.97  ;11.91  ;11.85; 11.79;  11.72;  11.65;...
 11.56  ;11.46  ;11.35  ;11.17; 10.59];

f = fit( x, y,'cubicinterp')
Nisarg
  • 1,631
  • 6
  • 19
  • 31
SrnLord
  • 111
  • 5
  • I have a question and a suggestion. My question is whether the first data point was taken under a no-load condition, as the voltage at time zero does not appear to have the voltage drop normally associated with the internal battery resistance in series with a load as is visible for the other data points. My suggestion is to use time units that have smaller values, for example if the time units are milliseconds then try modeling with units of seconds as the "x" values are currently very large. – James Phillips Jun 08 '18 at 20:14
  • 1
    This is because the lab test was done at intervals of 1 hour, which for me is a very large interval, it should be seconds. In this way the hysteresis effect was lost in the beginning. – SrnLord Jun 09 '18 at 16:12
  • If the experimental conditions (presence of charge/discharge hysteresis) for the time zero data point is different than that of all other data points, not using the time zero data point in the model is worth consideration. – James Phillips Jun 10 '18 at 12:55

1 Answers1

1

You can use gradient of y/x:

f = fit( x, y,'cubicinterp')
df = gradient(f(x)); % f'x
dx = gradient(x);    % dx

dfx = df ./ dx;
plot(x, y, x, dfx); 
StaticBeagle
  • 5,070
  • 2
  • 23
  • 34