% demoTrapz.m
%   demonstrate integration techniques by integrating
%   gaussian
%      Author: Peter Peachfuzz

%% set parameters
N=101;
width=0.25;
xmin=-1*width;
xmax=+1*width;
x0=0;

%% tabulate function
x=linspace(xmin, xmax, N);
g=gauss(x, x0, width);

%% calculate integral with trapz
Int=trapz(x,g);

%% display result and plot
disp(['Integral =', num2str(Int,8)]);
plot(x, g);
xlabel('x');
ylabel('g');