t=0:0.5:2;
x=[0.8 1 0.5 2 1];
integral = sum(x(2:end).*(t(2:end) - t(1:end-1))) 
