function h = g_smooth(width)
% function h = g_smooth(width)
%
% G_SMOOTH  -- Produces the impulse reponse for a Gaussian
%              FIR filter with adjustable width
%
% Input Parameters:
%   width   -- specifies the standard deviation of the filter
%
% Output Parameters:
%   h       -- the resulting gaussian filter, normalized
%              so that sum(h) = 1
%

if width <= 0
    h = 1;
else
    x = 0:max(4*width,1);
    x = [fliplr(x) x(2:end)]';
    h = exp(-(x/width).^2/2);
    
    if length(h) > 3
        h(h < .001) = [];
    end
    h = h/sum(h);
end