8 lines
147 B
Mathematica
8 lines
147 B
Mathematica
|
|
function integral = trapezoidalIntegration(f,a,b,n)
|
||
|
|
|
||
|
|
format long;
|
||
|
|
x = linspace(a,b,n); %define x-axis
|
||
|
|
integral = trapz( x,f(x) );
|
||
|
|
|
||
|
|
end
|