The lines in the MatLab® script might look like this:
n = 10
T = 0.0
T = T + (x(i)-x(i-1))*(f(i)+f(i-1))/2.0
end