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: mdFnn.m
    path of file: ./repos/mdembedding
    
    the code of the file until where you have to start completion: function [fnnPerc, embTimes] = mdFnn(data, tau, varargin)
%MDFNN The mdfnn function computes the percentage of false nearest
%   neighbors for multidimensional time series as a function of embedding
%   dimension based on Kennel, M. B., Brown, R., & Abarbanel, H. D. (1992).
%   Determining embedding dimension for phase-space reconstruction using a
%   geometrical construction. Physical review A, 45, 3403.
%
%   Inputs:
%   Required arguments:
%    data = an m*n matrix, were m is the number of data points and n is the
%    number of dimensions of the time series.
%
%    tau = time delay for embedding.
%
%   Optional arguments:
%    maxEmb = maximum number of embedding dimensions that are considered.
%     Default is 10.
%
%    doPlot = plot false nearest neighbors if 1, supress plot if 0.
%     Default is 1.
%
%    noSamples = number of randomly drawn coordinates from phase-space used
%     to estimate the percentage of false-nearest neighors.
%     eflaut is 500.
%
%    Rtol = First distance criterion for separating false neighbors.
%     Default is 10.
%
%    Atol = Second distance criterion for separating false neighbors.
%     Default is 2.
%
%   Outputs:
%    fnnPerc = percentage of false neighbors for each embedding.
%  
%    embTimes = number of times the multidimensional time series was
%     embedded with delay tau. Note, that embTimes = 1 means no embedding,
%     and embTimes = 2 means embedding the multidimensional time series
%     once. Hence, the resulting falase neibor percentages result from
%     embeddeding data (embTimes - 1) times
%
%   Version: 1.0, 22 June 2018
%   Authors:
%     Sebastian Wallot, Max Planck Insitute for Empirical Aesthetics
%     Dan Moenster, Aarhus University
%
%   Reference:
%     Wallot, S., \& M{\o}nster, D. (2018). Calculation of average mutual
%     information (AMI) and false-nearest neighbors (FNN) for the
%     estimation of embedding parameters of multidimensional time-series in
%     Matlab. Front. Psychol. - Quantitative Psychology and Measurement
%     (under review)

%
% Parse and validate the input
%
parser = inputParser;

% Required parameter tau, must be positive integer
checkTau = @(x) validateattributes(x, {'numeric'}, {'positive', 'numel', 1});

% Optional parameter: maxEmb
defaultMaxEmb = 10;
checkMaxEmb = @(x) isnumeric(x) && isscalar(x) && (x > 1) && (mod(x, 1) == 0);

% Optional parameter: doPlot, must be either 0 or 1 or true or false
defaultDoPlot = 1;
checkDoPlot = @(x) ((x == 0) || (x == 1)) || ((x ==  true) || (x == false));


    
function [fnnPerc, embTimes] = mdFnn(data, tau, varargin)
%MDFNN The mdfnn function computes the percentage of false nearest
%   neighbors for multidimensional time series as a function of embedding
%   dimension based on Kennel, M. B., Brown, R., & Abarbanel, H. D. (1992).
%   Determining embedding dimension for phase-space reconstruction using a
%   geometrical construction. Physical review A, 45, 3403.
%
%   Inputs:
%   Required arguments:
%    data = an m*n matrix, were m is the number of data points and n is the
%    number of dimensions of the time series.
%
%    tau = time delay for embedding.
%
%   Optional arguments:
%    maxEmb = maximum number of embedding dimensions that are considered.
%     Default is 10.
%
%    doPlot = plot false nearest neighbors if 1, supress plot if 0.
%     Default is 1.
%
%    noSamples = number of randomly drawn coordinates from phase-space used
%     to estimate the percentage of false-nearest neighors.
%     eflaut is 500.
%
%    Rtol = First distance criterion for separating false neighbors.
%     Default is 10.
%
%    Atol = Second distance criterion for separating false neighbors.
%     Default is 2.
%
%   Outputs:
%    fnnPerc = percentage of false neighbors for each embedding.
%  
%    embTimes = number of times the multidimensional time series was
%     embedded with delay tau. Note, that embTimes = 1 means no embedding,
%     and embTimes = 2 means embedding the multidimensional time series
%     once. Hence, the resulting falase neibor percentages result from
%     embeddeding data (embTimes - 1) times
%
%   Version: 1.0, 22 June 2018
%   Authors:
%     Sebastian Wallot, Max Planck Insitute for Empirical Aesthetics
%     Dan Moenster, Aarhus University
%
%   Reference:
%     Wallot, S., \& M{\o}nster, D. (2018). Calculation of average mutual
%     information (AMI) and false-nearest neighbors (FNN) for the
%     estimation of embedding parameters of multidimensional time-series in
%     Matlab. Front. Psychol. - Quantitative Psychology and Measurement
%     (under review)

%
% Parse and validate the input
%
parser = inputParser;

% Required parameter tau, must be positive integer
checkTau = @(x) validateattributes(x, {'numeric'}, {'positive', 'numel', 1});

% Optional parameter: maxEmb
defaultMaxEmb = 10;
checkMaxEmb = @(x) isnumeric(x) && isscalar(x) && (x > 1) && (mod(x, 1) == 0);

% Optional parameter: doPlot, must be either 0 or 1 or true or false
defaultDoPlot = 1;
checkDoPlot = @(x) ((x == 0) || (x == 1)) || ((x ==  true) || (x == false));

% Optional parameter: numSamples
defaultNumSamples = 500;
checkNumSamples = @(x) isnumeric(x) && isscalar(x) && (x > 1) && (mod(x, 1) == 0);

% Optional parameter: Rtol
checkRtol = @(x) validateattributes(x, {'numeric'}, {'positive', 'numel', 1});
defaultRtol = 10;

% Optional parameter: Atol
checkAtol = @(x) validateattributes(x, {'numeric'}, {'positive', 'numel', 1});
defaultAtol = 2;

% Do the parsing
addRequired(parser, 'data', @checkData);
addRequired(parser, 'tau', checkTau);
addOptional(parser, 'maxEmb', defaultMaxEmb, checkMaxEmb);
addOptional(parser, 'doPlot', defaultDoPlot, checkDoPlot);
addOptional(parser, 'numSamples', defaultNumSamples, checkNumSamples);
addOptional(parser, 'Rtol', defaultRtol, checkRtol);
addOptional(parser, 'Atol', defaultAtol, checkAtol);
parse(parser, data, tau, varargin{:});

% Get the optional arguments if provided. Otherwise the specified defaults
% are used.
maxEmb = parser.Results.maxEmb;
doPlot = parser.Results.doPlot;
numSamples = parser.Results.numSamples;
Rtol = parser.Results.Rtol;
Atol = parser.Results.Atol;

%
% Function to check input data, used by the input parser
%
function check = checkData(x)
   check = false;
   if (~isnumeric(x))
       error('Input is not numeric');
   elseif (numel(x) <= 1)
       error('Input must be a vector or matrix');
   else
       check = true;
   end