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!