function ndx = mysub2ind(siz,subinds)
%MYSUB2IND Customized version of the function mysub2ind 
%which can handle several multi-indices (arranged in rows) at once. 
%
%Each row of subinds contains a multi-index which is converted into a
%sequential index occupying the corresponding position of the output.
%
%  Input arguments:
%
%  siz : dimensions of the array whose sequential indices are computed
%  subinds : matrix containing multi-indices in its rows
%
%   CBVK Toolbox
%   JHMG, PMSB 2016

k = [1 cumprod(siz(1:end-1))];
ndx = ones(size(subinds,1),1);
for c = 1:size(subinds,2)
    for r = 1:size(subinds,1)
        v = subinds(r,c);
        ndx(r) = ndx(r) + (v-1)*k(c);
    end;
end