Personel Information

BSc: Physics Department, Middle East Technical University (METU), Ankara, Turkey
MSc: Physics Department, METU
PhD: Qualified, Physics Department, METU


Monday, July 11, 2016

INTEGRAL (TRAPEZOIDAL RULE)


## This m-file computes the integral of a function f over the
## equally spaced points x using the trapezoidal rule.
function I = trapezoid(x,f)
h = x(2)-x(1);
N = length(f);
I = 0;
for n=2:N-1,
I = I + h*f(n);
endfor
I = I + h/2*(f(1) + f(N));
endfunction

No comments:

Post a Comment