Home > matpower4.1 > i2e_field.m

i2e_field

PURPOSE ^

I2E_FIELD Converts fields of MPC from internal to external bus numbering.

SYNOPSIS ^

function mpc = i2e_field(mpc, field, ordering, dim)

DESCRIPTION ^

I2E_FIELD   Converts fields of MPC from internal to external bus numbering.

   MPC = I2E_FIELD(MPC, FIELD, ORDERING)
   MPC = I2E_FIELD(MPC, FIELD, ORDERING, DIM)

   For a case struct using internal indexing, this function can be
   used to convert other data structures as well by passing in 2 or 3
   extra parameters in addition to the case struct.

   If the 2nd argument is a string or cell array of strings, it
   specifies a field in the case struct whose value should be
   converted by I2E_DATA. In this case, the corresponding
   OLDVAL is taken from where it was stored by EXT2INT in
   MPC.ORDER.EXT and the updated case struct is returned.
   If FIELD is a cell array of strings, they specify nested fields.

   The 3rd and optional 4th arguments are simply passed along to
   the call to I2E_DATA.

   Examples:
       mpc = i2e_field(mpc, {'reserves', 'cost'}, 'gen');

       Reorders rows of mpc.reserves.cost to match external generator
       ordering.

       mpc = i2e_field(mpc, {'reserves', 'zones'}, 'gen', 2);

       Reorders columns of mpc.reserves.zones to match external
       generator ordering.

   See also E2I_FIELD, I2E_DATA, INT2EXT.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mpc = i2e_field(mpc, field, ordering, dim)
0002 %I2E_FIELD   Converts fields of MPC from internal to external bus numbering.
0003 %
0004 %   MPC = I2E_FIELD(MPC, FIELD, ORDERING)
0005 %   MPC = I2E_FIELD(MPC, FIELD, ORDERING, DIM)
0006 %
0007 %   For a case struct using internal indexing, this function can be
0008 %   used to convert other data structures as well by passing in 2 or 3
0009 %   extra parameters in addition to the case struct.
0010 %
0011 %   If the 2nd argument is a string or cell array of strings, it
0012 %   specifies a field in the case struct whose value should be
0013 %   converted by I2E_DATA. In this case, the corresponding
0014 %   OLDVAL is taken from where it was stored by EXT2INT in
0015 %   MPC.ORDER.EXT and the updated case struct is returned.
0016 %   If FIELD is a cell array of strings, they specify nested fields.
0017 %
0018 %   The 3rd and optional 4th arguments are simply passed along to
0019 %   the call to I2E_DATA.
0020 %
0021 %   Examples:
0022 %       mpc = i2e_field(mpc, {'reserves', 'cost'}, 'gen');
0023 %
0024 %       Reorders rows of mpc.reserves.cost to match external generator
0025 %       ordering.
0026 %
0027 %       mpc = i2e_field(mpc, {'reserves', 'zones'}, 'gen', 2);
0028 %
0029 %       Reorders columns of mpc.reserves.zones to match external
0030 %       generator ordering.
0031 %
0032 %   See also E2I_FIELD, I2E_DATA, INT2EXT.
0033 
0034 %   MATPOWER
0035 %   $Id: i2e_field.m,v 1.1 2011/11/09 21:32:13 cvs Exp $
0036 %   by Ray Zimmerman, PSERC Cornell
0037 %   Copyright (c) 2009-2011 by Power System Engineering Research Center (PSERC)
0038 %
0039 %   This file is part of MATPOWER.
0040 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0041 %
0042 %   MATPOWER is free software: you can redistribute it and/or modify
0043 %   it under the terms of the GNU General Public License as published
0044 %   by the Free Software Foundation, either version 3 of the License,
0045 %   or (at your option) any later version.
0046 %
0047 %   MATPOWER is distributed in the hope that it will be useful,
0048 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0049 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0050 %   GNU General Public License for more details.
0051 %
0052 %   You should have received a copy of the GNU General Public License
0053 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0054 %
0055 %   Additional permission under GNU GPL version 3 section 7
0056 %
0057 %   If you modify MATPOWER, or any covered work, to interface with
0058 %   other modules (such as MATLAB code and MEX-files) available in a
0059 %   MATLAB(R) or comparable environment containing parts covered
0060 %   under other licensing terms, the licensors of MATPOWER grant
0061 %   you additional permission to convey the resulting work.
0062 
0063 if nargin < 4
0064     dim = 1;
0065 end
0066 if ischar(field)
0067     mpc.order.int.(field) = mpc.(field);
0068     mpc.(field) = i2e_data(mpc, mpc.(field), ...
0069                     mpc.order.ext.(field), ordering, dim);
0070 else    %% iscell(field)
0071     for k = 1:length(field)
0072         s(k).type = '.';
0073         s(k).subs = field{k};
0074     end
0075     if ~isfield(mpc.order, 'int')
0076         mpc.order.int = [];
0077     end
0078     mpc.order.int = subsasgn(mpc.order.int, s, subsref(mpc, s));
0079     mpc = subsasgn(mpc, s, i2e_data(mpc, subsref(mpc, s), ...
0080         subsref(mpc.order.ext, s), ordering, dim));
0081 end

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