Reversing the cumtrapz function
显示 更早的评论
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 个评论
Mathieu NOE
2022-1-9
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
2022-1-12
Mathieu NOE
2022-1-12
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
2022-1-12
Noush
2022-1-12
回答(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'
类别
在 帮助中心 和 File Exchange 中查找有关 Power and Energy Systems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!