Home > matpower7.1 > lib > 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.

   The 2nd argument is a string or cell array of strings, specifying
   a field in the case struct whose value should be converted by
   a corresponding call to I2E_DATA. The field can contain either a
   numeric or a cell array. 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 %   The 2nd argument is a string or cell array of strings, specifying
0012 %   a field in the case struct whose value should be converted by
0013 %   a corresponding call to I2E_DATA. The field can contain either a
0014 %   numeric or a cell array. The corresponding OLDVAL is taken from
0015 %   where it was stored by EXT2INT in MPC.ORDER.EXT and the updated
0016 %   case struct is returned. If FIELD is a cell array of strings,
0017 %   they specify nested fields.
0018 %
0019 %   The 3rd and optional 4th arguments are simply passed along to
0020 %   the call to I2E_DATA.
0021 %
0022 %   Examples:
0023 %       mpc = i2e_field(mpc, {'reserves', 'cost'}, 'gen');
0024 %
0025 %       Reorders rows of mpc.reserves.cost to match external generator
0026 %       ordering.
0027 %
0028 %       mpc = i2e_field(mpc, {'reserves', 'zones'}, 'gen', 2);
0029 %
0030 %       Reorders columns of mpc.reserves.zones to match external
0031 %       generator ordering.
0032 %
0033 %   See also E2I_FIELD, I2E_DATA, INT2EXT.
0034 
0035 %   MATPOWER
0036 %   Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC)
0037 %   by Ray Zimmerman, PSERC Cornell
0038 %
0039 %   This file is part of MATPOWER.
0040 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0041 %   See https://matpower.org for more info.
0042 
0043 if nargin < 4
0044     dim = 1;
0045 end
0046 if ischar(field)
0047     mpc.order.int.(field) = mpc.(field);
0048     mpc.(field) = i2e_data(mpc, mpc.(field), ...
0049                     mpc.order.ext.(field), ordering, dim);
0050 else    %% iscell(field)
0051     for k = 1:length(field)
0052         s(k).type = '.';
0053         s(k).subs = field{k};
0054     end
0055     if ~isfield(mpc.order, 'int')
0056         mpc.order.int = [];
0057     end
0058     mpc.order.int = subsasgn(mpc.order.int, s, subsref(mpc, s));
0059     mpc = subsasgn(mpc, s, i2e_data(mpc, subsref(mpc, s), ...
0060         subsref(mpc.order.ext, s), ordering, dim));
0061 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005