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: ARFIT_arfit.m
    path of file: ./repos/hctsa/Toolboxes/ARFIT
    
    the code of the file until where you have to start completion: function [w, A, C, sbc, fpe, th]=ARFIT_arfit(v, pmin, pmax, selector, no_const)
%ARFIT	Stepwise least squares estimation of multivariate AR model.
%
%  [w,A,C,SBC,FPE,th]=ARFIT(v,pmin,pmax) produces estimates of the
%  parameters of an m-variate AR model of order p,
%
%      v(k,:)' = w' + A1*v(k-1,:)' +...+ Ap*v(k-p,:)' + noise(C),
%
%  where w is the (m x 1) intercept vector, A1, ..., Ap are (m x m)
%  coefficient matrices, and C is a (m x m) noise covariance
%  matrix. The estimated order p lies between pmin and pmax and is
%  chosen as the optimizer of Schwarz's Bayesian Criterion. 
% 
%  The input matrix v must contain the time series data, with
%  columns v(:,l) representing m variables l=1,...,m and rows
%  v(k,:) representing n observations at different (equally
%  spaced) times k=1,..,n. Optionally, v can have a third
%  dimension, in which case the matrices v(:,:, itr) represent  
%  the realizations (e.g., measurement trials) itr=1,...,ntr of the
%  time series. ARFIT returns least squares estimates of the
%  intercept vector w, of the coefficient matrices A1,...,Ap (as

    
function [w, A, C, sbc, fpe, th]=ARFIT_arfit(v, pmin, pmax, selector, no_const)
%ARFIT	Stepwise least squares estimation of multivariate AR model.
%
%  [w,A,C,SBC,FPE,th]=ARFIT(v,pmin,pmax) produces estimates of the
%  parameters of an m-variate AR model of order p,
%
%      v(k,:)' = w' + A1*v(k-1,:)' +...+ Ap*v(k-p,:)' + noise(C),
%
%  where w is the (m x 1) intercept vector, A1, ..., Ap are (m x m)
%  coefficient matrices, and C is a (m x m) noise covariance
%  matrix. The estimated order p lies between pmin and pmax and is
%  chosen as the optimizer of Schwarz's Bayesian Criterion. 
% 
%  The input matrix v must contain the time series data, with
%  columns v(:,l) representing m variables l=1,...,m and rows
%  v(k,:) representing n observations at different (equally
%  spaced) times k=1,..,n. Optionally, v can have a third
%  dimension, in which case the matrices v(:,:, itr) represent  
%  the realizations (e.g., measurement trials) itr=1,...,ntr of the
%  time series. ARFIT returns least squares estimates of the
%  intercept vector w, of the coefficient matrices A1,...,Ap (as
%  A=[A1 ... Ap]), and of the noise covariance matrix C.
%
%  As order selection criteria, ARFIT computes approximations to
%  Schwarz's Bayesian Criterion and to the logarithm of Akaike's Final
%  Prediction Error. The order selection criteria for models of order
%  pmin:pmax are returned as the vectors SBC and FPE.
%
%  The matrix th contains information needed for the computation of
%  confidence intervals. ARMODE and ARCONF require th as input
%  arguments.
%       
%  If the optional argument SELECTOR is included in the function call,
%  as in ARFIT(v,pmin,pmax,SELECTOR), SELECTOR is used as the order
%  selection criterion in determining the optimum model order. The
%  three letter string SELECTOR must have one of the two values 'sbc'
%  or 'fpe'. (By default, Schwarz's criterion SBC is used.) If the
%  bounds pmin and pmax coincide, the order of the estimated model
%  is p=pmin=pmax. 
%
%  If the function call contains the optional argument 'zero' as the
%  fourth or fifth argument, a model of the form
%
%         v(k,:)' = A1*v(k-1,:)' +...+ Ap*v(k-p,:)' + noise(C) 
%
%  is fitted to the time series data. That is, the intercept vector w
%  is taken to be zero, which amounts to assuming that the AR(p)
%  process has zero mean.
%
%  Modified 14-Oct-00
%           24-Oct-10 Tim Mullen (added support for multiple realizatons)
%
%  Authors: Tapio Schneider
%           tapio@gps.caltech.edu
%
%           Arnold Neumaier
%           neum@cma.univie.ac.at

  % n:   number of time steps (per realization)
  % m:   number of variables (dimension of state vectors) 
  % ntr: number of realizations (trials)
  [n,m,ntr]   = size(v);     

  if (pmin ~= round(pmin) | pmax ~= round(pmax))
    error('Order must be integer.');
  end