function index = mk_multi_index(n, dims, vals)
% MK_MULTI_INDEX Compute the indices of the submatrix where dims(i)=vals(i).
% index = mk_multi_index(n, dims, vals)
% 
% Example:
% A(:,:,1)=[1 2;3 4]; A(:,:,2)=[5 6; 7 8];
% index = mk_multi_index(3, [1 3], [1 2]);
% A(index{:}) = [5 6]: selects out row (dim 1) = 1 and plane (dim 3) = 2

index = cell(1,n);
for i=1:n
  index{i} = ':';
end
for i=1:length(dims)
  index{dims(i)} = vals(i);
end

