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: conf_region.m
    path of file: ./repos/CanlabCore/CanlabCore/Visualization_functions
    
    the code of the file until where you have to start completion: function [ax,ci,cen,ub,lb,S,e,lam,Fm,Fc,F,pval, msb] = conf_region(X,varargin)
% :Usage:
% ::
%
%    [ax,ci,cen,ub,lb,S,e,lam,Fm,Fc,F,pval, msb] = conf_region(X,[doplot])
%
% alternative conf region multivariate based on Johnson & Wichern, 4th ed., p. 236
% 2D (3D)
%
% :Outputs:
%
%   **ax:**
%        axes of confidence region, scaled to be half-length of confidence hyperellipsoid
%
%   **ci:**
%        length of axes of conf region (diagonal matrix), axes in reverse order of importance
%        as in ouput of eig
%
%   **cen:**
%        center of region (means of variables)
%
%   **ub:**
%        upper boundary coordinates for region, rows are dims (vars), cols index coordinates
%        last coordinate is on axis of greatest variation ("reverse order"), from output of eig
%
%   **lb:**
%        lower boundary coordinates
%        to plot, try: plot(ub(1,:),ub(2,:),'bo'); hold on; plot(lb(1,:),lb(2,:),'ro')
%
%   **S:**
%        covariance matrix
%
%   **e:**
%        eigenvectors
%
%   **lam:**
%        eigenvalues
%
%   **Fm:**
%        degrees of freedom multiplier, p(n-1) / n(n-p)
%
%   **Fc:**
%        critical F value based on alpha level
%
%   **F:**
%        F value for test - probably not quite right
%
%   **pval:**
%        p value for test - probably not quite right
%

    
function [ax,ci,cen,ub,lb,S,e,lam,Fm,Fc,F,pval, msb] = conf_region(X,varargin)
% :Usage:
% ::
%
%    [ax,ci,cen,ub,lb,S,e,lam,Fm,Fc,F,pval, msb] = conf_region(X,[doplot])
%
% alternative conf region multivariate based on Johnson & Wichern, 4th ed., p. 236
% 2D (3D)
%
% :Outputs:
%
%   **ax:**
%        axes of confidence region, scaled to be half-length of confidence hyperellipsoid
%
%   **ci:**
%        length of axes of conf region (diagonal matrix), axes in reverse order of importance
%        as in ouput of eig
%
%   **cen:**
%        center of region (means of variables)
%
%   **ub:**
%        upper boundary coordinates for region, rows are dims (vars), cols index coordinates
%        last coordinate is on axis of greatest variation ("reverse order"), from output of eig
%
%   **lb:**
%        lower boundary coordinates
%        to plot, try: plot(ub(1,:),ub(2,:),'bo'); hold on; plot(lb(1,:),lb(2,:),'ro')
%
%   **S:**
%        covariance matrix
%
%   **e:**
%        eigenvectors
%
%   **lam:**
%        eigenvalues
%
%   **Fm:**
%        degrees of freedom multiplier, p(n-1) / n(n-p)
%
%   **Fc:**
%        critical F value based on alpha level
%
%   **F:**
%        F value for test - probably not quite right
%
%   **pval:**
%        p value for test - probably not quite right
%
% :To plot:
% Either enter 1 or color as a 2nd argument, or do it yourself:
% ::
%
%    [ax,ci,cen,ub,lb,S,e,lam] = conf_region(X);
%    b = pinv([X(:,1) ones(size(X,1),1)] ) * X(:,2);
%    theta = atan(b(1)) - pi/2;
%    [h,h2] = plot_ellipse(cen(1),cen(2),theta,ci(1,1),ci(2,2));
%
% There is also an example for rend