GET_REORDER Returns A with one of its dimensions indexed. B = GET_REORDER(A, IDX, DIM) Returns A(:, ..., :, IDX, :, ..., :), where DIM determines in which dimension to place the IDX. See also SET_REORDER.
0001 function B = get_reorder(A, idx, dim) 0002 %GET_REORDER Returns A with one of its dimensions indexed. 0003 % 0004 % B = GET_REORDER(A, IDX, DIM) 0005 % 0006 % Returns A(:, ..., :, IDX, :, ..., :), where DIM determines 0007 % in which dimension to place the IDX. 0008 % 0009 % See also SET_REORDER. 0010 0011 % MATPOWER 0012 % Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC) 0013 % by Ray Zimmerman, PSERC Cornell 0014 % 0015 % This file is part of MATPOWER. 0016 % Covered by the 3-clause BSD License (see LICENSE file for details). 0017 % See https://matpower.org for more info. 0018 0019 ndim = ndims(A); 0020 s.type = '()'; 0021 s.subs = cell(1, ndim); 0022 for k = 1:ndim 0023 if k == dim 0024 s.subs{k} = idx; 0025 else 0026 s.subs{k} = ':'; 0027 end 0028 end 0029 B = subsref(A, s);