Home > matpower7.1 > lib > remove_userfcn.m

remove_userfcn

PURPOSE ^

REMOVE_USERFCN Removes a userfcn from the list to be called for a case.

SYNOPSIS ^

function mpc = remove_userfcn(mpc, stage, fcn)

DESCRIPTION ^

REMOVE_USERFCN Removes a userfcn from the list to be called for a case.
   MPC = REMOVE_USERFCN(MPC, STAGE, FCN)

   A userfcn is a callback function that can be called automatically by
   MATPOWER at one of various stages in a simulation. This function removes
   the last instance of the userfcn for the given STAGE with the function
   handle specified by FCN.

   See also ADD_USERFCN, RUN_USERFCN, TOGGLE_RESERVES, TOGGLE_IFLIMS,
   RUNOPF_W_RES.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mpc = remove_userfcn(mpc, stage, fcn)
0002 %REMOVE_USERFCN Removes a userfcn from the list to be called for a case.
0003 %   MPC = REMOVE_USERFCN(MPC, STAGE, FCN)
0004 %
0005 %   A userfcn is a callback function that can be called automatically by
0006 %   MATPOWER at one of various stages in a simulation. This function removes
0007 %   the last instance of the userfcn for the given STAGE with the function
0008 %   handle specified by FCN.
0009 %
0010 %   See also ADD_USERFCN, RUN_USERFCN, TOGGLE_RESERVES, TOGGLE_IFLIMS,
0011 %   RUNOPF_W_RES.
0012 
0013 %   MATPOWER
0014 %   Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC)
0015 %   by Ray Zimmerman, PSERC Cornell
0016 %
0017 %   This file is part of MATPOWER.
0018 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0019 %   See https://matpower.org for more info.
0020 
0021 n = length(mpc.userfcn.(stage));
0022 
0023 if have_feature('octave')
0024     fcn_info = functions(fcn);
0025     for k = n:-1:1
0026         cb_info = functions(mpc.userfcn.(stage)(k).fcn);
0027         if strcmp(cb_info.function, fcn_info.function)
0028             mpc.userfcn.(stage)(k) = [];
0029             break;
0030         end
0031     end
0032 else
0033     for k = n:-1:1
0034         if isequal(mpc.userfcn.(stage)(k).fcn, fcn)
0035             mpc.userfcn.(stage)(k) = [];
0036             break;
0037         end
0038     end
0039 end

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