GET_USERDATA Used to retrieve values of user data. VAL = OBJ.GET_USERDATA(NAME) returns the value specified by the given name or an empty matrix if userdata with NAME does not exist. This function allows the user to retrieve any arbitrary data that was saved in the object for later use. Data for a given NAME is saved by assigning it to OBJ.userdata.(NAME). This can be useful, for example, when using a user function to add variables or constraints, etc. 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 = get_userdata(obj, name) 0002 %GET_USERDATA Used to retrieve values of user data. 0003 % 0004 % VAL = OBJ.GET_USERDATA(NAME) returns the value specified by the given name 0005 % or an empty matrix if userdata with NAME does not exist. 0006 % 0007 % This function allows the user to retrieve any arbitrary data that was 0008 % saved in the object for later use. Data for a given NAME is saved by 0009 % assigning it to OBJ.userdata.(NAME). 0010 % 0011 % This can be useful, for example, when using a user function to add 0012 % variables or constraints, etc. Suppose some special indexing is 0013 % constructed when adding some variables or constraints. This indexing data 0014 % can be stored and used later to "unpack" the results of the solved case. 0015 % 0016 % See also OPT_MODEL. 0017 0018 % MP-Opt-Model 0019 % Copyright (c) 2008-2020, Power Systems Engineering Research Center (PSERC) 0020 % by Ray Zimmerman, PSERC Cornell 0021 % 0022 % This file is part of MP-Opt-Model. 0023 % Covered by the 3-clause BSD License (see LICENSE file for details). 0024 % See https://github.com/MATPOWER/mp-opt-model for more info. 0025 0026 if isfield(obj.userdata, name) 0027 rv = obj.userdata.(name); 0028 else 0029 rv = []; 0030 end