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: sub2ind_aps.m
    path of file: ./repos/bspm/thirdparty/MRtools_2015-08-21/Utilities
    
    the code of the file until where you have to start completion: function ndx = sub2ind_aps(siz,loc)
%==============================================================================
%%% This is a rewrite of the built-in matlab function that reworks how
%%% inputs are specified. Point locations are specified as a matrix rather
%%% than as a series of vectors. Comes in very handy if you don't know 
%%% matrix sizes in advance. Try "help sub2ind" for more details.
%%%
%%% Inputs:
%%% siz = matrix size (e.g. size(M))
%%%

    
function ndx = sub2ind_aps(siz,loc)
%==============================================================================
%%% This is a rewrite of the built-in matlab function that reworks how
%%% inputs are specified. Point locations are specified as a matrix rather
%%% than as a series of vectors. Comes in very handy if you don't know 
%%% matrix sizes in advance. Try "help sub2ind" for more details.
%%%
%%% Inputs:
%%% siz = matrix size (e.g. size(M))
%%%
%%% loc = a matrix of point locations (same width as number as length of
%%%     siz).
%%%
%%% Output:
%%% ndx = vector indcies for specified matrix subindices.
%%%
%%% Adapted by Aaron Schultz - aschultz@martinos.org

siz = double(siz);
if length(siz)<2
        error('MATLAB:sub2ind:InvalidSize',...
            'Size vector must have at least 2 elements.');
end