Do you know how to solve an integral over a loop?

1 回表示 (過去 30 日間)
Parham Babakhani Dehkordi
Parham Babakhani Dehkordi 2016 年 10 月 11 日
回答済み: Torsten 2016 年 10 月 11 日
Hi, I have a integral that I need to solve, the problem is that I have a loop, that is, for each value of r, Ihave one U, my inputs are:
r=[0 2.19 4.53 6.87 9.21 11.55 13.89 16.23 18.57 20.95 23.29 25.63 27.97 30.31 32.66 35.0 37.34 39.68 42.023 44.36 46.70 49.04 51.38];
U=[0 0 0 0.588 1.685 2.03 2.307 2.544 2.598 2.733 2.565 2.663 2.437 2.425 2.263 2.507 2.525 2.537 2.416 2.268 1.979 1.708 0.614];
Function is: F=2/(r^2) ∫U r dr
The bounds of integral are between 0 to 51.38 . Any help would be appreciated.
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 10 月 11 日
It does not make sense to integrate with respect to r if you have one U value for each r value.
It does not make sense to integrate with respect to a discrete variable.

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

採用された回答

Torsten
Torsten 2016 年 10 月 11 日
Ur=U.*r;
result=trapz(r,Ur);
gives you an approximation of
integral_{r=0}^{r=51.38} U*r dr.
Best wishes
Torsten.

その他の回答 (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