Calculate the integral of y = f(x) in [a,b] using Riemann Sum
contents of matlab code: intxy.m
% This function is used to calculate the integral of curve(x,y) in the % intveral (a,b)
% Created: 2010-04-14
function sum = intxy(x,y,a,b)
x_itvl = x(x>=a&x<=b); y_itvl = y(x>=a&x<=b);
x_diff = x_itvl(2:end)-x_itvl(1:end-1); sum = 0.5*x_diff*(y_itvl(1:end-1)' + y_itvl(2:end)');
Create Triangle distributed variables