How to get back the values of a curve from its cumulative integral value?

I have a amplitude distribution with time ( i.e. real curve, blak line). Then I did cumulative trapezoidal inegration of the curve using cumtrapz, which is represented by blue curve. Now, I again retain the real curve i.e. black curve from its cumulative integration i.e. blue curve. How I will get the real curve? Please provide me the suggestions. Thanks in advance.

 採用された回答

darova
darova 2021 年 4 月 5 日

0 投票

Use diff to find real curve from cumulative trapezoid result

6 件のコメント

AS
AS 2021 年 4 月 6 日
it is only showing zero values after applying diff.
AS
AS 2021 年 4 月 6 日
real curve in not returned.
See this
x = 0:0.1:10;
y = x.*sin(x); % original data
inty = cumtrapz(x,y); % integrated data
y1 = diff(inty)./diff(x); % return data
plot(x,y,'k')
line(x,inty,'color','r')
line(x(2:end),y1)
legend('original','integra','returned')
AS
AS 2021 年 4 月 7 日
Thank you so much for your clarification. But, in my problem it is not working. I have a matrix with dimension 64 by 1, where 1st column is having amplitude values (attached). Now, I am doing cumtrapz to obtain integral value and then did diff to retain original values. But, i am not getting the exact values as original. Could you please check it once.
darova
darova 2021 年 4 月 7 日
Works ok for me
clc,clear
y = load('data.txt');
x = 1:length(y);
inty = cumtrapz(x,y);
y1 = diff(inty)./diff(x);
plot(x,y,'r')
line(x,inty,'color','k','linestyle','--')
line(x(2:end),y1)
legend('original','returned')
AS
AS 2021 年 4 月 7 日
Thank you so much. I did mistake in length of the data. Now it is appropiate. Thanks a lot.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

AS
2021 年 4 月 5 日

コメント済み:

AS
2021 年 4 月 7 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by