Home > matpower4.1 > set_reorder.m

set_reorder

PURPOSE ^

SET_REORDER Assigns B to A with one of the dimensions of A indexed.

SYNOPSIS ^

function A = set_reorder(A, B, idx, dim)

DESCRIPTION ^

SET_REORDER Assigns B to A with one of the dimensions of A indexed.

   A = SET_REORDER(A, B, IDX, DIM)

   Returns A after doing A(:, ..., :, IDX, :, ..., :) = B
   where DIM determines in which dimension to place the IDX.

   See also GET_REORDER.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function A = set_reorder(A, B, idx, dim)
0002 %SET_REORDER Assigns B to A with one of the dimensions of A indexed.
0003 %
0004 %   A = SET_REORDER(A, B, IDX, DIM)
0005 %
0006 %   Returns A after doing A(:, ..., :, IDX, :, ..., :) = B
0007 %   where DIM determines in which dimension to place the IDX.
0008 %
0009 %   See also GET_REORDER.
0010 
0011 %   MATPOWER
0012 %   $Id: set_reorder.m,v 1.5 2010/04/26 19:45:25 ray Exp $
0013 %   by Ray Zimmerman, PSERC Cornell
0014 %   Copyright (c) 2009-2010 by Power System Engineering Research Center (PSERC)
0015 %
0016 %   This file is part of MATPOWER.
0017 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0018 %
0019 %   MATPOWER is free software: you can redistribute it and/or modify
0020 %   it under the terms of the GNU General Public License as published
0021 %   by the Free Software Foundation, either version 3 of the License,
0022 %   or (at your option) any later version.
0023 %
0024 %   MATPOWER is distributed in the hope that it will be useful,
0025 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0026 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0027 %   GNU General Public License for more details.
0028 %
0029 %   You should have received a copy of the GNU General Public License
0030 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0031 %
0032 %   Additional permission under GNU GPL version 3 section 7
0033 %
0034 %   If you modify MATPOWER, or any covered work, to interface with
0035 %   other modules (such as MATLAB code and MEX-files) available in a
0036 %   MATLAB(R) or comparable environment containing parts covered
0037 %   under other licensing terms, the licensors of MATPOWER grant
0038 %   you additional permission to convey the resulting work.
0039 
0040 ndim = ndims(A);
0041 s.type = '()';
0042 s.subs = cell(1, ndim);
0043 for k = 1:ndim
0044     if k == dim
0045         s.subs{k} = idx;
0046     else
0047         s.subs{k} = ':';
0048     end
0049 end
0050 A = subsasgn(A, s, B);

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005