You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: scale.m
    path of file: ./repos/CanlabCore/CanlabCore/Data_processing_tools
    
    the code of the file until where you have to start completion: function xout = scale(x,varargin)
% Centers and scales column vectors to mean 0 and st. deviation 1
%
% :Usage:
% ::
%
%     x = scale(x,[just center])

    
function xout = scale(x,varargin)
% Centers and scales column vectors to mean 0 and st. deviation 1
%
% :Usage:
% ::
%
%     x = scale(x,[just center])
%
% Notes:
% - This function will remove NaNs, but will remove ENTIRE row if any
% observation is NaN. This may be suboptimal for some applications.
% - In the future, this function should be renamed to avoid conflict with
% Matlab's internal scale.m, which could cause erratic behavior. This will
% require updating multiple other functions that call scale.m, however.

% ..
%    Programmer's notes:
%    2/17/14 - Luke: rewrote using vectorization instead of loop -MUCH FASTER!
%                   Still removes nans like original function
%    6/13/14 - Wani: after Luke's edit, mean-centering didn't work right.
%                   Fixed it.
%    9/12/18 - Wani: bugfix: changed 1e14 into 1e-14 in the line29. 1e14
%                   forced this function does meancentering only.
% ..


xout = NaN .* zeros(size(x));

[nanvec, x_no_nan] = nanremove(x);  %removes an entire row if any nan

% no data.  return original input.
if isempty(x_no_nan)
    xout = x;
    return
end