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-2015 by Power System Engineering Research Center (PSERC) 0018 % by Ray Zimmerman, PSERC Cornell 0019 % 0020 % $Id: userdata.m 2644 2015-03-11 19:34:22Z ray $ 0021 % 0022 % This file is part of MATPOWER. 0023 % Covered by the 3-clause BSD License (see LICENSE file for details). 0024 % See http://www.pserc.cornell.edu/matpower/ for more info. 0025 0026 if nargin == 3 0027 om.userdata.(name) = val; 0028 rv = om; 0029 else 0030 if isfield(om.userdata, name) 0031 rv = om.userdata.(name); 0032 else 0033 rv = []; 0034 end 0035 end