Home > matpower5.1 > get_reorder.m

get_reorder

PURPOSE ^

GET_REORDER Returns A with one of its dimensions indexed.

SYNOPSIS ^

function B = get_reorder(A, idx, dim)

DESCRIPTION ^

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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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-2015 by Power System Engineering Research Center (PSERC)
0013 %   by Ray Zimmerman, PSERC Cornell
0014 %
0015 %   $Id: get_reorder.m 2644 2015-03-11 19:34:22Z ray $
0016 %
0017 %   This file is part of MATPOWER.
0018 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0019 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0020 
0021 ndim = ndims(A);
0022 s.type = '()';
0023 s.subs = cell(1, ndim);
0024 for k = 1:ndim
0025     if k == dim
0026         s.subs{k} = idx;
0027     else
0028         s.subs{k} = ':';
0029     end
0030 end
0031 B = subsref(A, s);

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005