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: multivar_dist.m
    path of file: ./repos/CanlabCore/CanlabCore/diagnostics
    
    the code of the file until where you have to start completion: function [ds, S, p] = multivar_dist(X, varargin)
% multivariate normality checking and diagnostic plots
%
% :Usage:
% ::
%
%     [ds, S, p] = multivar_dist(X)
%
% :Input:
%
%     given matrix X with cases = rows, cols = variables
%
% :Optional input:
%

    
function [ds, S, p] = multivar_dist(X, varargin)
% multivariate normality checking and diagnostic plots
%
% :Usage:
% ::
%
%     [ds, S, p] = multivar_dist(X)
%
% :Input:
%
%     given matrix X with cases = rows, cols = variables
%
% :Optional input:
%
% 'noplot' : suppress plot
%
% :Outputs:
%
%   **ds:**
%        is matrix of squared distances, case numbers, and
%        expected chi2 values (in columns in this order)
%        rows are cases
%
%        NOTE: Sorted in order of ascend