USERDATA Used to save or retrieve values of user data. OM = USERDATA(OM, NAME, VAL) saves the value under the given name. VAL = USERDATA(OM, NAME) returns the value specified by the given name This function allows the user to save any arbitrary data in the object for later use. This can be useful when using a user function to add variables, constraints, costs, etc. For example, suppose some special indexing is constructed when adding some variables or constraints. This indexing data can be stored and used later to "unpack" the results of the solved case. See also OPT_MODEL.
0001 function rv = userdata(om, name, val) 0002 %USERDATA Used to save or retrieve values of user data. 0003 % 0004 % OM = USERDATA(OM, NAME, VAL) saves the value under the given name. 0005 % VAL = USERDATA(OM, NAME) returns the value specified by the given name 0006 % 0007 % This function allows the user to save any arbitrary data in the object 0008 % for later use. This can be useful when using a user function to add 0009 % variables, constraints, costs, etc. For example, suppose some special 0010 % indexing is constructed when adding some variables or constraints. 0011 % This indexing data can be stored and used later to "unpack" the results 0012 % of the solved case. 0013 % 0014 % See also OPT_MODEL. 0015 0016 % MATPOWER 0017 % Copyright (c) 2008-2016, Power Systems Engineering Research Center (PSERC) 0018 % by Ray Zimmerman, PSERC Cornell 0019 % 0020 % This file is part of MATPOWER. 0021 % Covered by the 3-clause BSD License (see LICENSE file for details). 0022 % See http://www.pserc.cornell.edu/matpower/ for more info. 0023 0024 if nargin == 3 0025 om.userdata.(name) = val; 0026 rv = om; 0027 else 0028 if isfield(om.userdata, name) 0029 rv = om.userdata.(name); 0030 else 0031 rv = []; 0032 end 0033 end