Trapezoidal numerical integration using for loops

22 次查看(过去 30 天)
Hi there,
I'm trying to create a for loop that calcuates the trapezoidal rule for a arrray of x and fx values without using the trapz function at different x points.
e.g.
x = 0, 0.25, 0.5, 0.75, 1
y = 0, 0.03, 0.006, 0.001, 0.06
Can someone please provide some guidance

回答(1 个)

James Tursa
James Tursa 2022-9-30
编辑:James Tursa 2022-9-30
See the Trapezoidal Method section here for the fomula:
or here:
Just write a for-loop to calculate the sum shown.

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by