%% Preprocess datamatrix X in canonical form
 % Y = preprocess(X, 'standard')
 % argument scl specifies scaler type 

function [X] = preprocess (X, scl)
	arguments
      X (:,:) double
      scl {mustBeMember(scl,["minmax","std"])}="std"
    end

    % Fill Missing values as linear interpolation
   	% of non-missing value 
    X = fillmissing(X, 'linear');

    %% Replace Outliers 
    X = filloutliers(X, 'center');

    %% Scale data using minmax scaler
    if scl == "minmax"
		X = normalize(X, 'range');

    %% Scale using standard scaler
    else 
 		X = normalize(X, 'zscore');
    end
end
