Delta=1
x=2:Delta:10
y=1./x;
I=MyTrapezoidal(y,Delta)
%Check with MATLAB
Imatlab=Delta*trapz(y)
function I=MyTrapezoidal(y,dx)
n=length(y);
I=dx*(sum(y)-(y(1)+y(n))/2.0);
end
Delta=1
x=2:Delta:10
y=1./x;
I=MyTrapezoidal(y,Delta)
%Check with MATLAB
Imatlab=Delta*trapz(y)
function I=MyTrapezoidal(y,dx)
n=length(y);
I=dx*(sum(y)-(y(1)+y(n))/2.0);
end