How to write a function that takes an interval [a,b] and a function f(x) and computes the integral of f(x) from a to b using the Trapezium rule.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How to write a function that takes an interval [a,b] and a function f(x) and computes the integral of f(x) from a to b using the Trapezium rule? Then, how do I use it on f(x)=sin(x) with [a,b]=[0,pi/2]?
0 Kommentare
Antworten (1)
Mathieu NOE
am 26 Okt. 2020
hello
refer to trapz and cumtrapz functions
example below
a = 0;
b = pi/2;
x = linspace(a,b,100);
y =sin(x);
out_integral = trapz(x,y);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!