For numerical integration you have a broad number of functions at your disposal:
trapz
quad
quadgk
integral
for uni-dimensional integration.
If, instead, you are interested in multi-dimensional integration techniques, you may think of making use of the following functions
dblquad
quad2d
integral2
integral3
EDIT
In your case, I would proceed this way:
x = 0:.1:2;
y = x;
trapz(x,y);
or
y = @(x) x;
quad(y,0,2);
EDIT 2
Give this a look:
clc,clear
s = 0:7;
y = @(x) x;
k = 1;
for ii = 1:numel(s)-1
f(k) = quad(y,s(k), s(k+1));
k = k + 1;
end
sum(f)