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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by