% Plot values of \int_{x0}^{x} f(t) dt for values of x from xmin to xmax.
% Makes use of the function Trap.m

% Input: xmin = left end of interval
%        xmax = right end of interval
%        m = how many points to plot
%        n = how many trapezoids to use for each interval

% Output: IntValues = a matrix where the first column is values of x
% between xmin and xmax, and whose second column is corresponding integral
% values. This function also produces a corresponding plot.

function IntValues = FTC(xmin,xmax,m,n)

% Determine the distance between points
dx = (xmax - xmin)/m;

% Loop to fill in the rest
for i = 0:m
   IntValues(i+1,:) = [(xmin+i*dx) Trap(xmin,xmin+i*dx,n*i)];
end

plot(IntValues(:,1),IntValues(:,2),'r.')
hold on;
plot(IntValues(:,1),f(IntValues(:,1)),'b.')
hold off;