Reversing the cumtrapz function
Mostrar comentarios más antiguos
Hi, I have created integral values in a table with the cumtrapz function. The cumtrapz values represent the capacity of a battery. Now, I'd like to reverse it, in order to find the power values of the battery, and plot those on a graph. So probably I need differentiate the values so that I get the y-values I need to plot it. What is the funciton for that? My table looks like this, as you can see, the first column are datetime values. Column 6 and 7 are the cumtrapz values that I want to differentiate over the first column:

6 comentarios
Mathieu NOE
el 9 de En. de 2022
hello
seems like your time increment is constant and equal to 1 hour
it shouldn't be too much complicated to compute the derivatives using either diff or gradient (in conjunction with dt = 1 hour)
Noush
el 12 de En. de 2022
Mathieu NOE
el 12 de En. de 2022
can you share your data ?
What is the power value of the battery at the initial time ?
Once you have fixed this value (say y(1)), you get the values for later times recursively:
y(i+1) = 2*Y(i)-y(1)-2*sum_{j=1}^{i} y(j)
This follows directly from how the capacity values Y are computed from the power values y with "cumtrapz":
Y(1) = (y(1)+y(2))/2
Y(2) = (y(1)+y(2))/2 + (y(2)+y(3))/2 = y(1)/2 + y(2)+ y(3)/2
...
Noush
el 12 de En. de 2022
Noush
el 12 de En. de 2022
Respuestas (1)
One way, using func2mat from,
x=rand(1,10)
y=cumtrapz(x);
A=func2mat(@cumtrapz, ones(size(x)), 'doSparse', 0 );
A(1)=1;
y(1)=x(1);
x_recovered=y/A'
Categorías
Más información sobre Power and Energy Systems en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!