Home > matpower5.0 > @opt_model > userdata.m

userdata

PURPOSE ^

USERDATA Used to save or retrieve values of user data.

SYNOPSIS ^

function rv = userdata(om, name, val)

DESCRIPTION ^

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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 %   $Id: userdata.m 2048 2012-05-03 12:59:07Z cvs $
0018 %   by Ray Zimmerman, PSERC Cornell
0019 %   Copyright (c) 2008-2012 by Power System Engineering Research Center (PSERC)
0020 %
0021 %   This file is part of MATPOWER.
0022 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0023 %
0024 %   MATPOWER is free software: you can redistribute it and/or modify
0025 %   it under the terms of the GNU General Public License as published
0026 %   by the Free Software Foundation, either version 3 of the License,
0027 %   or (at your option) any later version.
0028 %
0029 %   MATPOWER is distributed in the hope that it will be useful,
0030 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0031 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0032 %   GNU General Public License for more details.
0033 %
0034 %   You should have received a copy of the GNU General Public License
0035 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0036 %
0037 %   Additional permission under GNU GPL version 3 section 7
0038 %
0039 %   If you modify MATPOWER, or any covered work, to interface with
0040 %   other modules (such as MATLAB code and MEX-files) available in a
0041 %   MATLAB(R) or comparable environment containing parts covered
0042 %   under other licensing terms, the licensors of MATPOWER grant
0043 %   you additional permission to convey the resulting work.
0044 
0045 if nargin == 3
0046     om.userdata.(name) = val;
0047     rv = om;
0048 else
0049     if isfield(om.userdata, name)
0050         rv = om.userdata.(name);
0051     else
0052         rv = [];
0053     end
0054 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005