Integration from a plot

17 ビュー (過去 30 日間)
Carlos Imbaquingo
Carlos Imbaquingo 2019 年 9 月 2 日
コメント済み: Robert U 2019 年 9 月 2 日
I need to plot the integral of a function, but I only have the data. I would like to avoid using polyplot and apparently cumtrapz does not work. I just compared with an easy integration. For instance.
x = 0:pi/100;2*pi;
f = sin(x); % imaging this is the given data
g = cumtrapz(x,f); % Integration.
The result should be g = -cos(x), but instead I got g = -cos(x)+1
  1 件のコメント
Robert U
Robert U 2019 年 9 月 2 日
The result of the integration should be
g = -cos(x) + A
where A is the integration constant. Since cumtrapz() is the cumulative trapezoidal numerical integration, the boundary condition is set to
g(0) = 0
resulting in
A = 1
Kind regards,
Robert

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by