% smooth.m                                           Steve Mann, 1992/1993
%
% similar to smooth in PV-Wave or IDL
%
% Example: B=smooth(A,5)           % smooths and pads with NaN to get same size
%
%          B=smooth(A,3,'No padding with NaN') % doesn't pad with NaN
%                 %  any third input argument keeps it from padding with nan
%
% for other options like ``full'', ``same'', ``valid'', ``nan'', ``mirror'',...
% see smooth_old.m
% which is improperly written (inefficient) but enumerates many more options

%function B=wave_is_better_than_matlab(A,boxsize,method)
function B=wave_is_better_than_matlab(A,boxsize,nonan,nonormalize)

%if nargin ==3
%  disp('smooth: ignoring third input arg.; no longer used with smooth calling filt2d')
%end%if

if max(size(boxsize)) > 1
  error('smooth: boxsize must be a scalar')
end%if
if boxsize < 1
  error('smooth: boxsize must be positive integer')
end%if

if ~rem(boxsize,2)
  disp('|--------------------------------------------------------------|')
  disp('| boxsize must be even for image to be same size and unshifted |')
  disp('|--------------------------------------------------------------|')
end%if

filt=ones(1,boxsize);  % filt2d doesn't care if row or col vector
if nargin==2
  B=filt2d(A,filt)/boxsize.^2;
end%if
if nargin==3
  B=filt2d(A,filt,'not padding with NaN')/boxsize.^2;
end%if
if nargin==4
  B=filt2d(A,filt,'not padding with NaN','not normalizing');
end%if

