
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%  Title: StatisCLAS: A Package of Classification Methods   %%%%
%%%%  Author: David Casado de Lucas                            %%%%
%%%%  Version: 29th May 2013                                   %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% PURPOSE: This function applies the cubic splines smoothing method.

% INPUT VARIABLES:
%    numberMethod: Number of the smoothing method to be applied.
%    functions: Matrix with the functions as rows.
%    t: Grid of points of the independent variable.

% OUTPUT VARIABLES:
%    smoothedFunctions: Matrix with the smoothed functions as rows.

% COMMENTS:
%   (1) The smoothing method, based on the function 'csaps()', needs the Curve Fitting Toolbox of MATLAB.
%   (2) The user can easily add new smoothing methods.

function smoothedFunctions = smoothingFD(numberMethod, functions, t)
  switch numberMethod
    case 1
      h = 1/length(t);
      p = 1/(1+h^3/6);
      [smoothedFunctions,p] = csaps(t,functions,p,t); % This function belongs to the Curve Fitting Toolbox of MATLAB.
  end
end
